题解:CF2038J Waiting for...

· · 题解

非常朴实无华的模拟题。

令当前车站人数为 P_{\text{station}}

当来了 p_i 人时:我们使 P_{\text{station}} 增加 p_i

当来了有 b_i 个空座的公交车时:

附代码:

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios :: sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, p = 0;
    for(cin >> n; n --; )
    {
        char op; int x;
        cin >> op >> x;
        if(op == 'P') p += x;
        else
        {
            if(p < x) puts("YES"), p = 0;
            else puts("NO"), p -= x;
        }
    }
    return 0;
}

本文来自:

另附官方题解。