fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7.  
  8. int n;
  9. cin >> n;
  10. vector<long long> a(n);
  11. for(int i=0;i<n;i++) cin >> a[i];
  12.  
  13. vector<long long> b = a;
  14. sort(b.begin(), b.end());
  15.  
  16. for(int i=0;i<n;i++){
  17. for(int k=i+2;k<n;k++){
  18. long long s = b[i] + b[k];
  19. if(s % 2) continue;
  20. long long mid = s / 2;
  21. if(binary_search(b.begin()+i+1, b.begin()+k, mid)){
  22. cout << b[i] << " " << mid << " " << b[k];
  23. return 0;
  24. }
  25. }
  26. }
  27.  
  28. cout << "0 0 0";
  29. }
Success #stdin #stdout 0.01s 5320KB
stdin
7
5 1 -7 2 -1 3 6
stdout
-7 -1 5