| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 142336 | 万嘉宇 | 18第一次出现与最后一次出现的位置 | C++ | Output Limit Exceeded | 1 MS | 284 KB | 689 | 2026-01-06 19:35:22 |
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ long long a[2001],n,x,s=0; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i];} cin>>x; for(int i=1;i<=n;i++){ if(a[i]==x){ cout<<i<<" ";break; }} for(int i=n+1;i>=1;i--){ if(a[i]==x){ cout<<i;break; }} for(int i=1;i<=n;i++){ if(a[i]==x){ s++;} if(s==0){ cout<<"-1"; }} return 0; }