fork download
  1. // Problem: B. Worms Evolution
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. void solve()
  6. {
  7. int n;
  8. cin >> n;
  9. vector<int> a(n);
  10. for (int i = 0; i < n; i++)
  11. {
  12. cin >> a[i];
  13. }
  14. for (int i = 0; i < n; i++)
  15. {
  16. for (int j = 0; j < n; j++)
  17. {
  18. if (j == i)
  19. continue;
  20. for (int k = 0; k < n; k++)
  21. {
  22. if (a[i] == (a[j] + a[k]))
  23. {
  24. if (k == i || k == j)
  25. continue;
  26. cout << i + 1 << " " << j + 1 << " " << k + 1;
  27. return;
  28. }
  29. }
  30. }
  31. }
  32. cout << -1;
  33. }
  34. int main()
  35. {
  36. int t = 1;
  37. // cin >> t;
  38. while (t--)
  39. {
  40. solve();
  41. }
  42. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
1 2 3