记录编号 |
556526 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
[CSP 2019J]交通换乘 |
最终得分 |
100 |
用户昵称 |
jingci |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.841 s |
提交时间 |
2020-10-22 22:23:15 |
内存使用 |
9.67 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
struct Youhui {
int time;
int price;
bool yong;
Youhui() {
yong = false;
}
};
vector<Youhui> v;
bool can(int time, int price, Youhui b) {
return price <= b.price && time - b.time <= 45 && !b.yong;
}
int main() {
freopen("csp2019pj_transfer.in", "r", stdin);
freopen("csp2019pj_transfer.out", "w", stdout);
int n;
cin >> n;
int m = 0;
int k = 0;
for (int i = 0; i < n; i++) {
int gj;
cin >> gj;
if (gj == 0) {
Youhui a;
cin >> a.price >> a.time;
v.push_back(a);
m += a.price;
}
else {
int t, p;
cin >> p >> t;
m += p;
bool youhui = false;
for (int j = k; j < v.size(); j++) {
if (t - v[j].time > 45) {
k = j + 1;
}
if (can(t, p, v[j])) {
youhui = true;
v[j].yong = true;
m -= p;
break;
}
}
}
}
cout << m;
return 0;
}