| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 151942 | 何兴驰 | 18第一次出现与最后一次出现的位置 | C++ | Accepted | 1 MS | 288 KB | 437 | 2026-04-19 12:27:46 |
#include<bits/stdc++.h> using namespace std; int main(){ int n,m,q=-1,o=-1; cin>>n; int a[n+1]; for(int z=1;z<=n;z++){ cin>>a[z]; } cin>>m; for(int i=1;i<=n;i++){ if(m==a[i]){ q=i; break; } } for(int i=n;i>=1;i--){ if(m==a[i]){ o=i; break; } } if(o==-1){ cout<<-1; }else{ cout<<q<<" "<<o; } return 0; }