跳到正文

题解

P14505 [NCPC 2025] km/h

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

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
题目
P14505

版本

  1. v1当前

1. 题目分析

阅读理解题。

主要考虑国家限速。由于我们并不知道国家限速具体是多少,只知道它高于任何限速标识,所以我们只能取最保守的速度值,也就是大于先前所有限速标识的最小整十数。

如果有明确限速,直接输出这个限速就好了。反之,则输出大于先前所有限速标识的最小整十数。

2. 代码

C++
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n,mx=0;cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        if(s=="/")cout<<(mx/10+1)*10<<"\n";
        else mx=max(mx,stoi(s)),cout<<stoi(s)<<"\n";
    }
    return 0;
}
原文