ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#186604 | #851. 公交换乘 | AndyLuo | 100 | 119ms | 1996kb | C++11 | 969b | 2023-10-01 10:13:00 | 2023-10-01 10:13:02 |
answer
#include <bits/stdc++.h>
using namespace std;
long long read() {
long long x = 0,f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') {
f = -1;
}
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
long long n,type,price,t,pre,newpre,ans;
struct node {
long long price,t;
bool f;
};
vector<node> v;
int main() {
n = read();
for (int i = 1; i <= n; i++) {
type = read(),price = read(),t = read();
if (!(type)) {
v.push_back({price,t,true});
ans += price;
} else {
while (t - v[pre].t > 45) {
pre++;
if (pre == v.size()) {
ans += price;
break;
}
}
newpre = pre;
while (v[newpre].price < price || !(v[newpre].f)) {
newpre++;
if (newpre == v.size()) {
ans += price;
break;
}
}
v[newpre].f = false;
}
}
cout << ans;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 1212kb
input:
100 0 85 6 1 61 35 0 117 44 0 114 45 0 182 47 1 19 48 1 52 49 0 265 838 1 408 866 0 946 867 1 86 872...
output:
21240
result:
ok single line: '21240'
Test #2:
score: 5
Accepted
time: 0ms
memory: 1208kb
input:
200 0 261 132 0 400 161 0 249 197 1 554 202 0 661 203 1 105 204 1 408 205 0 476 543 1 769 553 0 846 ...
output:
48175
result:
ok single line: '48175'
Test #3:
score: 5
Accepted
time: 0ms
memory: 1220kb
input:
400 0 241 273 0 208 276 1 100 297 1 105 300 1 143 303 1 255 304 1 72 305 0 216 306 1 48 307 1 331 30...
output:
99096
result:
ok single line: '99096'
Test #4:
score: 5
Accepted
time: 0ms
memory: 1232kb
input:
800 0 278 290 1 234 311 1 29 312 0 953 316 0 460 326 1 421 328 0 701 329 0 776 330 0 108 331 1 504 3...
output:
198270
result:
ok single line: '198270'
Test #5:
score: 5
Accepted
time: 0ms
memory: 1228kb
input:
1000 0 139 550 1 167 589 0 123 823 0 93 854 1 123 855 1 159 858 1 3 861 1 6 863 1 94 864 1 189 865 1...
output:
251527
result:
ok single line: '251527'
Test #6:
score: 5
Accepted
time: 0ms
memory: 1228kb
input:
1000 0 315 307 0 703 312 1 590 325 1 78 326 1 545 333 1 583 334 1 378 338 1 198 341 1 492 343 1 30 3...
output:
275868
result:
ok single line: '275868'
Test #7:
score: 5
Accepted
time: 0ms
memory: 1632kb
input:
50000 0 321 7 0 321 18 0 321 44 0 321 47 1 321 48 0 321 49 1 321 51 0 321 130 1 321 131 0 321 154 1 ...
output:
11524221
result:
ok single line: '11524221'
Test #8:
score: 5
Accepted
time: 7ms
memory: 1996kb
input:
80000 0 334 32 1 334 44 0 334 60 1 334 61 1 334 65 1 334 66 0 334 67 1 334 68 1 334 69 1 334 70 1 33...
output:
19191974
result:
ok single line: '19191974'
Test #9:
score: 5
Accepted
time: 5ms
memory: 1996kb
input:
100000 0 344 63 1 344 83 1 344 93 0 344 100 0 344 101 0 344 103 1 344 104 1 344 105 1 344 106 1 344 ...
output:
24739448
result:
ok single line: '24739448'
Test #10:
score: 5
Accepted
time: 6ms
memory: 1996kb
input:
80000 0 480 4 0 480 18 1 480 37 1 480 47 0 480 48 1 480 49 1 480 51 1 480 52 1 480 55 1 480 56 1 480...
output:
27551040
result:
ok single line: '27551040'
Test #11:
score: 5
Accepted
time: 12ms
memory: 1996kb
input:
100000 0 493 623 1 493 648 1 493 650 1 493 654 1 493 660 1 493 661 1 493 662 0 493 664 1 493 665 1 4...
output:
35354016
result:
ok single line: '35354016'
Test #12:
score: 5
Accepted
time: 15ms
memory: 1992kb
input:
100000 0 503 11 1 503 39 0 503 45 1 503 46 0 503 150 0 503 166 0 503 184 1 503 185 0 503 187 1 503 1...
output:
36149101
result:
ok single line: '36149101'
Test #13:
score: 5
Accepted
time: 6ms
memory: 1632kb
input:
50000 0 377 261 0 552 299 0 182 302 1 5 305 0 385 717 1 51 746 1 653 754 1 182 759 1 715 760 1 563 7...
output:
13038408
result:
ok single line: '13038408'
Test #14:
score: 5
Accepted
time: 10ms
memory: 1996kb
input:
60000 0 367 781 1 144 790 1 362 810 1 689 814 1 556 815 1 622 816 1 676 818 1 34 819 0 444 820 1 584...
output:
15653349
result:
ok single line: '15653349'
Test #15:
score: 5
Accepted
time: 12ms
memory: 1996kb
input:
80000 0 172 798 0 975 801 1 190 828 1 120 830 0 861 836 1 23 839 0 26 875 1 21 881 1 11 883 1 26 903...
output:
20891633
result:
ok single line: '20891633'
Test #16:
score: 5
Accepted
time: 5ms
memory: 1996kb
input:
80000 0 348 6 1 56 21 1 491 25 0 30 27 0 354 31 1 300 34 1 685 37 1 460 38 1 317 39 0 389 40 1 645 4...
output:
20842471
result:
ok single line: '20842471'
Test #17:
score: 5
Accepted
time: 9ms
memory: 1996kb
input:
100000 0 209 815 1 19 826 1 209 848 1 381 852 1 29 853 1 197 854 0 8 855 1 261 856 1 310 857 1 393 8...
output:
26186051
result:
ok single line: '26186051'
Test #18:
score: 5
Accepted
time: 11ms
memory: 1996kb
input:
100000 0 385 31 0 325 60 1 642 64 1 559 71 1 658 73 0 245 80 1 11 103 1 481 121 0 227 967 1 105 999 ...
output:
26338428
result:
ok single line: '26338428'
Test #19:
score: 5
Accepted
time: 9ms
memory: 1992kb
input:
100000 0 190 3 1 163 39 1 8 40 1 300 41 0 404 42 1 290 43 1 325 44 1 240 45 1 131 47 0 32 68 0 917 9...
output:
26294656
result:
ok single line: '26294656'
Test #20:
score: 5
Accepted
time: 12ms
memory: 1996kb
input:
100000 0 412 577 0 747 585 1 384 601 1 269 605 1 385 607 1 412 608 0 824 609 1 17 610 1 774 611 0 31...
output:
26064375
result:
ok single line: '26064375'