Mai intai trebuie sa te autentifici.
Cod sursa(job #2279242)
| Utilizator | Data | 9 noiembrie 2018 11:13:03 | |
|---|---|---|---|
| Problema | Numarare triunghiuri | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <fstream>
#include <algorithm>
using namespace std;
ifstream in("nrti.in");
ofstream out("nrtri.out");
const int L=16;
const int N = 100001;
int v[N];
int n;
int main()
{
int n,nr=0,s, a, b;
in>>n;
for(int i=0;i<n;i++){
in>>v[i];
}
sort(v,v+n);
int r = 0;
int pas = 1<<L;
for(int i=n-1;i!=0;i--){
for(int j=i-1;j!=0;j--){
s=v[i]+v[j];
a=n-1;
b=j;
while(pas>b){
if(r+pas<=n && v[r+pas]<s){
r+=pas;
nr=r-b;
}
pas/=2;
}
}
}
out<<nr;
return 0;
}
