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, ×);
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;
}
过不了样例 1
样例 1:
6
0 10 3
1 5 46
0 12 50
1 3 96
0 5 110
1 6 135
正确答案:
36
我的答案:
36