Run ID:2413

提交时间:2024-01-06 12:42:49

# include<iostream> using namespace std; int main() { int n,m; cin>>n; int lst[n], first=n, last=-1; for(int i = 0; i < n; i++) { cin>>lst[i]; } cin>>m; for(int i = 0; i < n; i++) { if(lst[i] == m) { if(i<first) { first=i; } if(i>last) { last=i; } } } if(first==n) { printf("-1"); } else { printf("%d %d", first+1, last+1); } return 0; }