Cod sursa(job #2654870)
Utilizator | Data | 2 octombrie 2020 16:30:12 | |
---|---|---|---|
Problema | Numarare triunghiuri | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include<fstream>
#include<algorithm>
using namespace std;
int main(){
ifstream in("nrtri.in");
ofstream out("nrtri.out");
long long int v[800],n,l=0;
in>>n;
for(int i=0;i<n;i++){
in>>v[i];
}
sort(v,v+n);
for(long long int i=0;i<n-2;i++){
if(v[i]+v[i+1]>=v[i+2]){
l++;
}
}
out<<l;
}