Cod sursa(job #2840544)
Utilizator | Data | 27 ianuarie 2022 23:22:35 | |
---|---|---|---|
Problema | Numarare triunghiuri | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n=4;
vector<int>v={2,3,7,4};
int s=0;
sort(v.begin(),v.end());
for(int i=0;i<n-2;i++)
for(int j=i+1;j<n-1;j++)
{
auto it=upper_bound(v.begin()+j+1,v.end(),v[i]+v[j]);
s += it - (v.begin()+j+1);
}
cout<<s;
return 0;
}