Information
- ID
- 1528
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 73
- Accepted
- 23
- Uploaded By
水题
#include<bits/stdc++.h>
using namespace std;
int path[100000];
int t,num,car,i;
void search(int []){
int ans=0;
for(int j=0;j<i;j++)
{
if(path[j] > ans)
ans = path[j];
}
if(ans == 0)
cout<<-1<<endl;
else
cout<<ans<<endl;
}
int main() {
std::ios::sync_with_stdio(false);
cin>>t;
while(t--){
stack<int> cnt;
cin>>num;
if(num == 1){
cin>>car;
path[i++] = car;
cnt.push(car);
}
else if(num == 2){
cnt.pop();
i--;
path[i]=0;
}
else
search(path);
}
return 0;
}
By signing up a 追梦算法网 universal account, you can submit code and join discussions in all online judging services provided by us.