Pagini recente » Cod sursa (job #2249178) | Rating Ovidiu Rosca (junior) | Rating George Popa (QSilver) | Cod sursa (job #3296742)
#include <fstream>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int main()
{
int n, v[800], x, y, z;
long long ct = 0;
fin >> n;
for(int i = 0; i < n; i++){
fin >> v[i];
}
for(int i = 0; i < n-2; i++){
for(int j = i+1; j < n-1; j++){
for(int k = j + 1; k < n; k++){
x = v[i];
y = v[j];
z = v[k];
if(x < y){
swap(x,y);
}
if(x < z){
swap(x,z);
}
if(x <= y + z){
ct++;
}
}
}
}
fout << ct;
return 0;
}