Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // prolem F
- #include <bits/stdc++.h>
- using namespace std;
- int n, a[100010], L[100010], R[100010];
- int main() {
- cin >> n;
- long long sum = 0;
- for (int i = 1; i <= n; i++) {
- cin >> a[i];
- sum += a[i];
- if (L[a[i]] == 0) { // первое вхождение числа a[i]
- L[a[i]] = i;
- }
- R[a[i]] = i; // последнее вхождение числа a[i]
- }
- for (int j = 1; j <= n; j++) {
- if ((sum + 1) % (a[j] + 1) != 0)
- continue;
- int x = (sum + 1) / (a[j] + 1) - 1;
- if (x > 0 && x <= 100000 && L[x] != 0 && L[x] != R[a[j]]) {
- if (L[x] < R[a[j]])
- cout << L[x] << ' ' << R[a[j]];
- else
- cout << R[a[j]] << ' ' << L[x];
- return 0;
- }
- }
- cout << -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement