fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. void file() {
  5. #ifndef ONLINE_JUDGE
  6. freopen("input.txt", "r", stdin);
  7. freopen("output.txt", "w", stdout);
  8. #endif
  9. ios::sync_with_stdio(false);
  10. cin.tie(nullptr);
  11. }
  12. void ELA7MOSE()
  13. {
  14. int n, mx = LLONG_MIN, tl, tr, t = 0, l = 0, r = 0;
  15. cin >> n;
  16. vector<int> a(n);
  17. for (int i = 0; i < n; i++) {
  18. cin >> a[i];
  19. if (a[i] > mx) mx = a[i], l = i + 1, r = i + 1;
  20. }
  21. for (int i = 0; i < n; i++) {
  22. if (a[i] == mx) {
  23. if (!t) tl = i + 1;
  24. tr = i + 1, t++;
  25. }
  26. if ((a[i] != mx || i == n - 1) && t) {
  27. if (abs(tr - tl) > abs(r - l)) l = tl, r = tr;
  28. t = 0;
  29. }
  30. }
  31. cout << mx << endl << l << " " << r;
  32. }
  33. signed main() {
  34. file();
  35. long long tc = 1;
  36. // cin >> tc;
  37. while (tc--) ELA7MOSE();
  38. }
Success #stdin #stdout 0s 5324KB
stdin
5
1 6 6 6 3
stdout
6
2 4