QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#461000 | #5036. 卑鄙的下毒人 | chroneZ | 20 | 316ms | 48772kb | C++17 | 2.4kb | 2024-07-02 15:00:38 | 2024-07-02 15:00:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 5e5 + 5;
int n, m, L[N], R[N];
ll k, a[N];
namespace K1 {
struct BIT {
ll t[N];
inline void add(int x, ll v) {for(; x <= n; x += x & -x) t[x] += v;}
inline ll query(int x) {ll r = 0; for(; x; x -= x & -x) r += t[x]; return r;}
inline ll rquery(int l, int r) {return query(r) - query(l - 1);}
} bit;
int id[N];
void Main() {
iota(id + 1, id + m + 1, 1);
sort(id + 1, id + m + 1, [](int x, int y) {
return R[x] < R[y];
});
ll ans = 0;
for(int _ = 1; _ <= m; _++) {
int i = id[_];
ll p = bit.rquery(L[i], R[i]);
if(p < a[i]) {
ans += a[i] - p;
bit.add(R[i], a[i] - p);
}
}
cout << ans << "\n";
}
}
namespace A1 {
struct BIT {
ll t[N];
inline void add(int x, ll v) {for(; x <= n; x += x & -x) t[x] += v;}
inline void radd(int l, int r, ll v) {add(l, v), add(r + 1, -v);}
inline ll query(int x) {ll r = 0; for(; x; x -= x & -x) r += t[x]; return r;}
} bit;
struct Range {
int l, r, id;
inline friend bool operator < (Range A, Range B) {
return A.r < B.l;
}
};
multiset<Range> S;
bool ban[N];
int id[N];
void Main() {
iota(id + 1, id + m + 1, 1);
sort(id + 1, id + m + 1, [](int x, int y) {
return R[x] < R[y];
});
for(int i = 1; i <= m; i++) {
bit.radd(L[i], R[i], 1);
S.insert({L[i], R[i], i});
}
ll ans = 0;
for(int _ = 1; _ <= m; _++) {
int i = id[_];
if(ban[i]) continue;
ll p = bit.query(R[i]);
if(p < k) {
ans++;
bit.radd(L[i], R[i], -1);
ban[i] = 1;
} else {
ans += k;
for(auto it = S.find({L[i], R[i], i}); it != S.end(); it = S.find({L[i], R[i], i})) {
auto [l, r, id] = *it; S.erase(it);
if(ban[id]) continue;
ban[id] = 1;
bit.radd(l, r, -1);
}
}
}
cout << ans << "\n";
}
}
int main() {
// freopen("kfc.in", "r", stdin);
// freopen("kfc.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n >> m >> k;
for(int i = 1; i <= m; i++) {
cin >> L[i] >> R[i] >> a[i];
}
if(k == 1) return K1::Main(), 0;
if(*max_element(a + 1, a + m + 1) == 1) return A1::Main(), 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 11756kb
input:
7 20 5 3 4 1 1 1 1 2 7 1 3 7 1 2 2 1 3 7 1 4 6 1 7 7 1 5 5 1 1 6 1 3 4 1 1 4 1 3 6 1 3 3 1 2 5 1 1 1 1 5 5 1 1 1 1 6 7 1 2 2 1
output:
34
result:
wrong answer 1st words differ - expected: '15', found: '34'
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 11912kb
input:
1794 5000 5 419 430 46802829 1071 1140 167141363 1154 1554 366136993 735 1265 152210166 387 1104 646459531 1073 1637 525871859 1340 1729 44303243 1221 1574 588158235 91 478 922877048 1117 1268 460323230 315 1103 378106915 272 1071 784282054 1147 1469 220209516 281 375 514585737 677 1031 231082599 55...
output:
result:
wrong answer Unexpected EOF in the participants output
Subtask #3:
score: 20
Accepted
Test #31:
score: 20
Accepted
time: 133ms
memory: 21168kb
input:
322675 500000 1 162058 177924 125740423 72321 188693 51206015 73706 159883 238256306 223634 241332 292316893 8164 94217 879196279 232892 319246 624760769 67688 195525 319652781 70831 92026 394982900 68675 156743 598333126 107804 308096 843245966 57077 248406 291662171 12794 193657 560389007 105560 2...
output:
480886198651
result:
ok "480886198651"
Test #32:
score: 0
Accepted
time: 130ms
memory: 21292kb
input:
252531 500000 1 73336 89104 198033994 117801 178724 312536059 83164 115804 819989513 1359 145774 511306394 47527 143191 383786500 1003 48236 76011634 125645 183182 48474946 106010 149967 927727206 103952 112384 125439208 104139 173611 971831922 92285 136188 923537157 1086 180210 427446035 23210 2210...
output:
475010855091
result:
ok "475010855091"
Test #33:
score: 0
Accepted
time: 123ms
memory: 21072kb
input:
249992 490700 1 214479 214496 515365625 14206 14382 334019307 217230 217309 735689827 63924 63925 258401277 12070 12079 934649204 207338 207371 758583044 37166 37413 417324175 126526 126539 124700076 55914 56166 936572436 216053 216093 893982405 45801 46192 131912638 241657 241696 730127825 116589 1...
output:
24050495775217
result:
ok "24050495775217"
Test #34:
score: 0
Accepted
time: 136ms
memory: 20780kb
input:
249997 494845 1 85695 85706 947011452 173987 175115 969606646 50884 50893 735552086 44292 44297 627665457 215893 215931 539749179 110666 111348 593653974 37171 38363 554044675 152491 152726 857012755 128775 129900 279287672 171922 172278 447261487 123925 123930 105674353 54822 54901 583760389 133139...
output:
18391590923314
result:
ok "18391590923314"
Test #35:
score: 0
Accepted
time: 131ms
memory: 20440kb
input:
249935 497717 1 48307 48437 56342637 151763 152298 861912241 19415 19415 927311192 59828 60101 204305982 147582 147862 395948999 186343 186386 10643541 44713 44853 524618914 192169 192211 648592572 188253 188338 998141500 34052 34721 466660212 156785 156916 59576841 202401 202629 971241453 139207 13...
output:
12964165809186
result:
ok "12964165809186"
Test #36:
score: 0
Accepted
time: 122ms
memory: 19644kb
input:
249950 496942 1 62391 62983 157267127 207325 208422 715495951 29165 29192 834359395 91599 91615 332629666 84504 85813 5574214 55544 55732 893133907 68164 68179 848654383 229512 230081 808984107 165586 165713 454872244 200207 201999 968200081 65750 65806 299499692 202042 202614 558169368 140195 14188...
output:
14606631340114
result:
ok "14606631340114"
Test #37:
score: 0
Accepted
time: 133ms
memory: 20448kb
input:
249982 495670 1 86390 86526 783248482 9407 9411 540434263 238452 238534 830682740 91200 91302 364033820 145244 147442 35874704 21309 21354 781112886 220232 221381 997542261 99464 99511 240733162 20848 21196 714567934 164306 164325 993562838 151641 151665 555186611 95172 95199 763915769 189851 189962...
output:
16988476067185
result:
ok "16988476067185"
Test #38:
score: 0
Accepted
time: 119ms
memory: 20360kb
input:
237809 500000 1 1 1 725340623 2 2 556538685 2 3 750113351 2 4 89997667 1 5 176278822 6 6 628044473 4 7 376781143 4 8 691054257 8 9 681694326 8 10 107877180 10 11 895699579 8 12 309610008 9 13 583966770 11 14 91473484 15 15 795666681 14 16 199439006 17 17 235804033 18 18 459166246 15 19 261822162 19 ...
output:
54827431453285
result:
ok "54827431453285"
Test #39:
score: 0
Accepted
time: 123ms
memory: 17592kb
input:
193004 500000 1 1 1 418968490 1 2 696290526 1 3 35413858 2 4 468838187 1 5 249430274 3 6 574413613 4 7 399467033 6 8 75065642 6 9 340727930 6 10 862056055 7 11 902270161 11 12 246578995 12 13 245100768 14 14 911540131 13 15 88554299 13 16 454499535 13 17 232059626 16 18 908692431 15 19 139531524 20 ...
output:
44183387167347
result:
ok "44183387167347"
Test #40:
score: 0
Accepted
time: 120ms
memory: 20788kb
input:
168037 500000 1 1 1 571104806 2 2 127213141 2 3 975939427 3 4 132217350 5 5 894810748 3 6 490775217 4 7 25203836 6 8 458117768 6 9 426044363 8 10 745181289 9 11 432989435 10 12 578165354 9 13 68938921 12 14 793934534 11 15 74005157 16 16 311972043 14 17 625329955 18 18 168234200 15 19 465554170 18 2...
output:
38680733724403
result:
ok "38680733724403"
Test #41:
score: 0
Accepted
time: 121ms
memory: 20468kb
input:
177842 500000 1 1 1 421267539 2 2 773838708 3 3 174145748 2 4 345791748 4 5 178857721 6 6 63445539 5 7 785501019 6 8 293135367 7 9 107408904 6 10 781833072 7 11 380579169 11 12 149601052 13 13 941321725 13 14 68117336 14 15 878597414 14 16 501204638 15 17 856015182 14 18 474203866 18 19 851148153 16...
output:
40928382637201
result:
ok "40928382637201"
Test #42:
score: 0
Accepted
time: 108ms
memory: 20756kb
input:
177915 500000 1 1 1 271292280 2 2 625813925 1 3 939340374 2 4 84776571 5 5 456945542 3 6 191363078 7 7 78237995 4 8 723718315 6 9 199913337 7 10 276964318 11 11 475214330 11 12 956526724 9 13 234753935 11 14 850526973 13 15 377635279 12 16 866464127 16 17 72950802 17 18 54563404 15 19 532673622 20 2...
output:
40869789096961
result:
ok "40869789096961"
Test #43:
score: 0
Accepted
time: 132ms
memory: 21372kb
input:
278352 500000 1 170913 214543 168974049 78160 236308 127212570 22624 192783 758327554 33353 119675 112500515 123238 138960 773944493 102641 104678 525298818 39746 265269 231933608 101566 199878 496386445 160697 214573 875085547 138890 189675 304621779 72230 233413 82446355 93697 111582 716259833 248...
output:
470663510567
result:
ok "470663510567"
Test #44:
score: 0
Accepted
time: 138ms
memory: 20564kb
input:
313114 500000 1 192852 245567 319309601 97135 304118 787617405 76891 190936 17692495 9880 226269 747702459 117760 188046 398275162 61120 289318 158491038 41844 216947 23254041 48629 302643 629285602 262794 301320 933483522 23187 211531 218319925 31448 106981 97268677 32372 191357 161506602 87160 272...
output:
469269376470
result:
ok "469269376470"
Test #45:
score: 0
Accepted
time: 131ms
memory: 20900kb
input:
205945 500000 1 146039 176990 894969853 61417 89219 764910645 37405 123868 427213499 64826 75839 220017382 85594 128873 116882220 186391 190027 882212569 5498 54259 155371726 21164 123514 490637163 96788 187848 376113236 35647 185488 993192042 36184 39246 792947747 108807 165538 393657269 83958 1120...
output:
483741106377
result:
ok "483741106377"
Test #46:
score: 0
Accepted
time: 136ms
memory: 19920kb
input:
500000 500000 1 496837 496870 923496382 278362 278392 357421464 274060 274061 345429203 65297 65317 503103187 236352 236398 120593170 181125 181172 197502113 123694 123736 224553449 130956 130974 786534231 134569 134606 55741322 12360 12365 286706634 300281 300328 410270588 236167 236193 832854993 4...
output:
33887394129829
result:
ok "33887394129829"
Test #47:
score: 0
Accepted
time: 137ms
memory: 19956kb
input:
500000 500000 1 51275 51298 906550332 91442 91490 890797911 483126 483169 880126619 438390 438400 604056812 23577 23608 201153018 112465 112503 146011563 84539 84565 351378223 60262 60277 458827584 305983 306004 140042073 312033 312044 18883706 238027 238047 356335074 163624 163668 134261442 272969 ...
output:
33962870370969
result:
ok "33962870370969"
Test #48:
score: 0
Accepted
time: 131ms
memory: 21044kb
input:
500000 500000 1 57535 57553 874794489 443359 443368 328379248 73189 73203 567826431 200304 200308 552526649 271876 271909 231476665 378433 378453 495669857 108553 108584 431003982 42176 42197 773752461 93371 93401 797605414 404017 404032 25578235 361930 361979 209265 247150 247182 620036262 18378 18...
output:
33917735271253
result:
ok "33917735271253"
Test #49:
score: 0
Accepted
time: 136ms
memory: 21164kb
input:
500000 500000 1 330583 330583 819334510 342192 342225 251008140 23558 23562 693668995 7713 7745 20457747 358117 358150 397036939 484167 484203 505239528 314640 314645 449883400 40462 40503 485953240 77808 77832 572898847 147529 147564 337988142 189570 189614 949484749 453228 453254 752514208 364749 ...
output:
33900595789167
result:
ok "33900595789167"
Test #50:
score: 0
Accepted
time: 134ms
memory: 19512kb
input:
500000 500000 1 167444 167450 930275075 359867 359876 53239020 441544 441576 585496181 439743 439786 17684411 36167 36203 217051650 29078 29096 949040506 124064 124110 880111173 59505 59551 825248135 177726 177746 769432518 17759 17804 604866783 265114 265151 657157449 356894 356929 496106508 82971 ...
output:
33861714821089
result:
ok "33861714821089"
Subtask #4:
score: 0
Wrong Answer
Test #51:
score: 0
Wrong Answer
time: 316ms
memory: 48772kb
input:
194181 500000 5 22921 38709 1 103611 130117 1 33044 135246 1 25161 106036 1 13484 183424 1 129622 133239 1 103905 105727 1 8418 141108 1 5951 145648 1 61392 105830 1 139975 149309 1 47361 59947 1 91598 172246 1 32303 43094 1 72490 170121 1 68502 168603 1 56051 91019 1 106112 129606 1 70776 177996 1 ...
output:
1805945
result:
wrong answer 1st words differ - expected: '2485', found: '1805945'
Subtask #5:
score: 0
Wrong Answer
Test #66:
score: 0
Wrong Answer
time: 75ms
memory: 15104kb
input:
265199 500000 5 51732 151507 196279569 1147 251097 325871693 79410 120618 539045634 209514 221950 912376813 44813 147573 616444800 53619 134328 533306546 94940 108466 186490362 42483 236958 489649490 127349 167018 943263893 103970 193784 202963780 197001 221033 210521750 5815 113674 152090319 129972...
output:
result:
wrong answer Unexpected EOF in the participants output