| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 74455 | 邓嘉瑶 | 18第一次出现与最后一次出现的位置 | C++ | Output Limit Exceeded | 1 MS | 272 KB | 435 | 2024-05-25 12:04:24 |
#include<bits/stdc++.h> using namespace std; int n,sum=0,b,d; int main() { cin>>n; int a[n] ; for(int i=1; i<=n; i++) { cin>>a[i]; } int c; cin>>c; for(int i=1; i<n; i++) { if(a[i]==c) { b=i; cout<<b<<" "; break; } } for(int i=n; i>=0; i--) { if(a[i]==c) { d=i; cout<<d; break; } } for(int i=n; i>=0; i--) { if(a[i]!=c) { cout<<-1; } } return 0; }