fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4.  
  5. unordered_map <int, vector<int>> f;
  6. int a[5555];
  7. signed main()
  8. {
  9. ios_base::sync_with_stdio(false);
  10. cin.tie(0); cout.tie(0);
  11. int n, x; cin >> n >> x;
  12. for (int i = 1; i <= n; i++)
  13. {
  14. cin >> a[i];
  15. f[a[i]].push_back(i);
  16. }
  17. for (int i = 1; i < n; i++)
  18. for (int j = i + 1; j <= n; j++)
  19. if (a[i] + a[j] <= x && f.find(x - a[i] - a[j]) != f.end())
  20. {
  21. for (int id : f[x - a[i] - a[j]])
  22. if (id != i && id != j)
  23. cout << i << ' ' << j << ' ' << id;
  24. return 0;
  25. }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty