#include <iostream>
using namespace std;
/*
Declarăm și citim variabilele “x” și “n”.
Declaram vectorul “v”
Cu ajutorul unei structuri repetitive “for” citim șirul de “n” numere.
Declaram variabila “count” pe care o initializam cu valoarea zero.
Declaram variabila “start” si “end”.
Declaram “biggestCount” = 0, “biggestStart”, “biggestEnd”
Cu ajutorul unei structuri repetitive care rulează de la “1” la “n”:
Daca elementul curent e egal cu “x”:
Incrementam “count”.
Prima data cand intalnim valoarea lui x:
Variabila “start” va lua valoarea indicele curent.
“end” se actualizeaza mereu cu valoarea indicelui curent.
Daca “biggestCount” este mai mic decat “count”:
Actualizam pe “biggestCount” cu “count”
Actualizam pe “biggestStart” cu “start”.
Actualizam pe “biggestEnd” cu “end”.
Altfel:
Resetam variabilele “count”, “start” si “end”
Afisam “biggestStart”, “biggestEnd”.
*/
int main() {
int x, n;
cin >> x >> n;
int v[21];
for (int i = 1; i <= n; ++i) {
cin >> v[i];
}
int count = 0, start = 0, end, biggestCount = 0, biggestStart, biggestEnd;
for (int i = 1; i <= n; ++i) {
if (v[i] == x) {
++count;
if (start == 0) {
start = i;
}
end = i;
if (count > biggestCount) {
biggestCount = count;
biggestStart = start;
biggestEnd = end;
}
} else {
count = 0;
start = 0;
end = 0;
}
}
cout << biggestStart << " " << biggestEnd;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwovKgpEZWNsYXLEg20gyJlpIGNpdGltIHZhcmlhYmlsZWxlIOKAnHjigJ0gyJlpIOKAnG7igJ0uCkRlY2xhcmFtIHZlY3RvcnVsIOKAnHbigJ0KQ3UgYWp1dG9ydWwgdW5laSBzdHJ1Y3R1cmkgcmVwZXRpdGl2ZSDigJxmb3LigJ0gY2l0aW0gyJlpcnVsIGRlIOKAnG7igJ0gbnVtZXJlLgpEZWNsYXJhbSB2YXJpYWJpbGEg4oCcY291bnTigJ0gcGUgY2FyZSBvIGluaXRpYWxpemFtIGN1IHZhbG9hcmVhIHplcm8uC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