这道题目我们只需要维护一个最大值 ,接着等解除限速标志出现时输出 就好了,除了维护最大值应该就没有什么难的了。
AC Code:
#include<bits/stdc++.h>
using namespace std;
int n,nextmax;
string s;
int main(){
cin>>n;
while(n--){
cin>>s;
if(s=="/")
cout<<(nextmax/10+1)*10<<'\n';
else{
cout<<s<<'\n';
if(s.size()==3)nextmax=max((s[0]-'0')*100+(s[1]-'0')*10+s[2]-'0',nextmax);
else nextmax=max((s[0]-'0')*10+(s[1]-'0'),nextmax);
}
}
return 0;
}