fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define int long long
  5. #define pb push_back
  6. #define fi first
  7. #define se second
  8. #define nn '\n'
  9. #define pi pair<ll,ll>
  10. #define unmp unordered_map
  11. #define uns unordered_set
  12. #define TASK ""
  13. int mod = 1e9+7;
  14. const int N = 5*1e3 + 5;
  15. int MOD = 998244353;
  16. int bit[200000];
  17. int n;
  18. int a[N];
  19. map<int, int> cnt;
  20. int kq = LLONG_MAX;
  21. int hehe = 0;
  22. signed main() {
  23. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  24. if(fopen(TASK".INP","r")){
  25. freopen(TASK".INP","r",stdin);
  26. freopen(TASK".OUT","w",stdout);
  27. }
  28. cin >> n;
  29. for(int i = 1; i <= n ; i++){
  30. cin >> a[i];
  31. cnt[ a[i] ]++;
  32. }
  33. sort(a + 1, a + 1 + n);
  34. for(int j = 2; j <= n - 1; j++){
  35. for(int i = 1; i <= j - 1; i++ ){
  36. int d = a[j] - a[i];
  37. if(d <= 0){
  38. continue;
  39. }
  40. int target = a[j]+ d;
  41. if(cnt[target] > 0 ){
  42. if(a[i] < kq){
  43. kq = a[i];
  44. hehe = d;
  45. }
  46. }
  47. }
  48. }
  49. if(kq == LLONG_MAX){
  50. cout << 0 << " " << 0 << " " << 0 << nn;
  51. }
  52. else{
  53. cout << kq << " " << kq + hehe << " " << kq + 2*hehe << nn;
  54. }
  55. return 0;
  56. }
  57.  
Success #stdin #stdout 0.01s 5312KB
stdin
5
-1 2 3 4 9
stdout
-1 4 9