噢莫加纳加加加 • 1天前
#include <bits/stdc++.h>
using namespace std;
struct piao {
int a, price, time;
};
piao t[100005];
int n, ans = 0;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
int a, price, time;
cin >> a >> price >> time;
t[i].a = a;
t[i].price = price;
t[i].time = time;
if (a == 0) {
ans = ans + price;
}
}
for (int i = 1; i <= n; i++) {
if (t[i].a == 1) {
int money = t[i].price;
int x = 0;
for (int j = i - 1; j >= 1 && (t[i].time - t[j].time ) <= 45; j--) {
if (t[j].a == 0 && t[j].price >= t[i].price ) {
money = 0;
x = j;
}
}
t[x].a = -1;
ans = ans + money;
}
}
cout << ans;
return 0;
}
评论:
请先登录,才能进行评论