Untitled
unknown
plain_text
a year ago
517 B
15
Indexable
#include <iostream>
#include <algorithm>
using namespace std;
int n, cnt, a[100000];
int main() {
cin >> n; for(int i = 0; i < n; i++) cin >> a[i];
sort(a, a+n);
cnt = 0;
for(int i = 0; i < n-2; i++){
for(int j = i+1; j < n-1; j++){
if(binary_search(a+j+1, a+n, a[i]+a[j])){
cnt++;
//cout << i << " " << j << " " << a[i] << " " << a[j] << endl;
}
}
}
cout << 2*cnt;
return 0;
}
/*
2 4 5 7 10 13
2 5 7
*/Editor is loading...
Leave a Comment