跳到正文

题解

题解:P14505 [NCPC 2025] km/h

Jason2013awa约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年11月13日
收录
2025年12月12日
更新
2026年11月12日
篇幅
约 1 分钟
题目
P14505

版本

  1. v1当前

若第 ii 行是数字,显然输出它即可,因为其小于国家限速;

若第 ii 行是 /,则最低国家车速为大于前面所有限速最大值的最小整十数,因为:

  1. 最低国家车速大于限速
  2. 最低国家车速为整十数

AC Code

C++
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=0;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        if(s=="/"){
            int tem=ans+1;
            while(tem%10!=0)tem++;
            cout<<tem<<endl;
        }else{
            int t=stoi(s);
            ans=max(ans,t);
            cout<<t<<endl;
        }
    }
    return 0;
}
原文