我在某某OJ上过了一道CSP的题目,但在洛谷上只拿了30分,题目的数据范围和题目内容也应该一样的,有没有人帮我看看是什么问题 :
#include <bits/stdc++.h>
using namespace std;
struct Node {
bool Flag;
int Price;
int Time;
} a[100050];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, ans = 0, head = 1, tail = 1;
cin >> n;
for (int i = 1; i <= n; i ++) {
bool check;
int price, _time;
cin >> check >> price >> _time;
if (!check) {
ans += price;
a[++ tail].Price = price;
a[tail].Time = _time;
} else {
bool flag = 0;
for (; head <= tail && a[head].Time + 45 <= _time; head ++);
for (int j = head; j <= tail; j ++) {
if (a[j].Price >= price && !a[j].Flag) {
flag = 1;
a[j].Flag = 1;
break;
}
}
if (!flag)
ans += price;
}
}
cout << ans;
return 0;
}