队列30分求调
查看原帖
队列30分求调
970949
CleverSea楼主2024/10/3 00:57

rt,测试点数据点我,两个样例都能过,一到评测听取WA声一片,求大佬指点!

#include <bits/stdc++.h>
using namespace std;

int n, ans;

struct Node
{
    int p, t;
};

queue<Node> q;

signed main()
{
    cin >> n;
    while (n--)
    {
        int a, p, t;
        cin >> a >> p >> t;
        while (!q.empty() && t - (q.front()).t > 45) q.pop();
        if (a == 0)
        {
            q.push({p, t});
            ans += p;
        }
        else
        {
            if (!q.empty() && (q.front()).p >= p) q.pop();
            else ans += p;
        }
    }
    cout << ans << endl;
    return 0;
}

2024/10/3 00:57
加载中...