Run ID:97003
提交时间:2024-11-10 10:37:46
#include<iostream> using namespace std; int main(){ int n,a[2000],m,first=-1,last=-1; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } cin>>m; for(int i=1;i<=n;i++){ if(a[i]==m){ first=i; break; } } for(int i=n;i>=1;i--){ if(a[i]==m){ last=i; break; } } if(first==-1)cout<<-1; else cout<<first<<" "<<last; return 0; }