Advertisement
Guest User

Untitled

a guest
Jan 1st, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. typedef long long ll;
  4. typedef unsigned long long ull;
  5. typedef long double ld;
  6. #define pb push_back
  7. #define X first
  8. #define Y second
  9. const ll mod = 998244353;
  10.  
  11. using namespace std;
  12.  
  13. ll n, x, ans, u, v, a[1001], b[5];
  14.  
  15. int main()
  16. {
  17. cin >> n;
  18. for (ll i = 0; i < 4; i++)
  19. {
  20. cin >> b[i];
  21. }
  22. for (ll i = 4; i < n; i++)
  23. {
  24. cin >> x;
  25. a[b[0]%112] = max(b[0], a[b[0]%112]);
  26. b[0] = b[1];
  27. b[1] = b[2];
  28. b[2] = b[3];
  29. b[3] = x;
  30. ll c = (112 - x%112)%112;
  31. if (a[c] <= x) continue;
  32. if (a[c] + x > ans)
  33. {
  34. ans = a[c] + x;
  35. u = a[c];
  36. v = x;
  37. }
  38. }
  39. if (ans == 0) cout << "-1";
  40. else cout << ans << endl << u << " " << v;
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement