离奇AC事件
查看原帖
离奇AC事件
741732
small_Dongpo楼主2023/8/29 19:49

AC 代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long l;
l n, ans = 0, price, times, a = 1, b = 0;
bool x, f = 0;

struct Subway
{
    l p, t;
    bool u;
} q[100005];

int main()
{
    scanf("%lld", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d%lld%lld", &x, &price, &times);
        if (!x)
        {
            q[++b] = {price, times, 0};
            ans += price;
        }
        else
        {
            while (a < b && q[a].t + 45 < times)
            {
                a++;
            }
            for (l j = a; j <= b; ++j)
            {
                if (q[j].p >= price && q[j].u == 0)
                {
                    q[j].u = 1;
                    f = 1;
                    break;
                }
            }
            if (!f) ans += price;
            f = 0;
        }
    }
    printf("%lld", ans);
    return 0;
}

过不了样例 11

样例 11:

6
0 10 3
1 5 46
0 12 50
1 3 96
0 5 110
1 6 135

正确答案:

36

我的答案:

36
2023/8/29 19:49
加载中...