QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#317774 | #5441. Quartz Collection | nguyentunglam | TL | 215ms | 3952kb | C++17 | 1.3kb | 2024-01-29 17:41:51 | 2024-01-29 17:41:51 |
Judging History
answer
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define endl "\n"
using namespace std;
const int N = 1e5 + 10;
int n, m;
int a[N], b[N];
int32_t main() {
#define task ""
cin.tie(0) -> sync_with_stdio(0);
if (fopen("task.inp", "r")) {
freopen("task.inp", "r", stdin);
freopen("task.out", "w", stdout);
}
if (fopen(task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
cin >> n >> m;
for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
auto get = [&] () {
vector<int> pos, neg;
long long ans = 0;
for(int i = 1; i <= n; i++) {
ans += a[i];
if (b[i] - a[i] >= 0) pos.push_back(b[i] - a[i]);
else neg.push_back(b[i] - a[i]);
}
sort(pos.begin(), pos.end(), greater<int> ());
sort(neg.begin(), neg.end(), greater<int> ());
for(int i = 1; i < pos.size(); i += 4) {
ans += pos[i];
if (i + 1 < pos.size()) ans += pos[i + 1];
}
for(int i = (int) pos.size() & 1 ^ 1; i < neg.size(); i += 2) {
ans += neg[i];
}
return ans;
};
cout << get() << endl;
while (m--) {
int t, x, y; cin >> t >> x >> y;
a[t] = x;
b[t] = y;
cout << get() << endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3880kb
input:
4 5 2 4 5 7 1 7 2 1 4 5 2 1 6 2 4 4 3 2 1 3 3 6 6
output:
13 14 15 14 10 13
result:
ok 6 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
1 1 1 1 1 1 1
output:
1 1
result:
ok 2 number(s): "1 1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
100 100 6 7 100 8 5 61 5 75 59 65 51 47 83 37 34 54 87 46 4 26 21 87 12 97 86 68 60 11 62 76 14 83 29 31 91 62 57 80 47 75 85 97 62 77 91 86 14 25 48 77 83 65 39 61 78 77 45 46 90 74 100 91 86 98 55 5 84 42 91 69 100 4 74 98 60 37 75 44 41 12 15 34 36 1 99 16 7 87 36 26 79 42 41 84 17 98 72 16 38 55...
output:
5109 5065 5060 5007 4975 4993 4950 4928 4922 4930 4948 4915 4885 4863 4898 4864 4837 4787 4793 4774 4730 4708 4659 4617 4546 4618 4654 4687 4677 4685 4714 4733 4728 4701 4660 4631 4628 4682 4743 4777 4764 4772 4754 4759 4715 4744 4672 4687 4700 4649 4611 4543 4523 4554 4605 4585 4532 4520 4489 4505 ...
result:
ok 101 numbers
Test #4:
score: 0
Accepted
time: 29ms
memory: 3712kb
input:
1000 1000 411 789 753 186 495 203 417 324 490 424 195 480 314 23 663 218 12 747 124 390 134 38 218 536 291 840 174 908 474 767 313 167 575 9 857 427 313 27 959 935 258 70 472 957 747 228 205 939 293 303 626 802 712 283 658 346 208 383 889 204 99 640 801 966 828 742 534 11 259 734 226 129 843 350 50 ...
output:
490601 490340 490353 490689 490697 490600 490571 491078 491388 491507 491729 491809 491984 492228 492161 492171 492384 492276 492693 492547 492372 492580 492350 492795 492635 492941 492936 492797 492359 492108 492670 492589 492570 492700 492910 492401 492274 492263 491905 491692 492032 492168 492350...
result:
ok 1001 numbers
Test #5:
score: 0
Accepted
time: 215ms
memory: 3688kb
input:
5000 1000 72520 61541 4609 95655 27768 67682 48763 4836 63868 3082 44496 5022 70138 88832 25864 48681 5212 79532 1134 60190 84561 98392 91027 55707 72938 83316 60044 93249 82269 88819 83951 6069 35302 29132 1882 68479 3489 45817 79436 37261 88849 763 23786 62641 89532 32244 85372 46815 6765 56651 27...
output:
249456797 249463957 249477751 249431759 249421636 249444892 249421159 249434259 249445362 249448397 249505520 249532943 249538838 249493562 249475570 249507883 249503390 249512573 249524766 249475431 249511948 249496484 249455533 249428931 249385128 249380512 249370595 249390331 249422343 249398748 ...
result:
ok 1001 numbers
Test #6:
score: 0
Accepted
time: 215ms
memory: 3720kb
input:
4990 1000 28197 37778 70449 79157 73746 9790 57859 34774 60067 24125 4809 99133 51444 84059 21094 41904 63475 27833 23189 61130 3203 19272 87649 64152 92473 74674 85227 38234 55074 55761 80744 89480 23995 39894 49024 88746 57815 10851 10032 29151 9757 78417 77993 19383 39272 26155 39279 69209 64005 ...
output:
250090553 250118970 250123190 250148475 250125939 250104267 250093819 250095617 250069068 250084722 250077812 250113699 250078954 250113860 250175483 250182518 250204543 250223709 250264020 250312567 250359944 250405159 250405818 250426052 250472672 250505450 250530824 250554819 250565666 250535021 ...
result:
ok 1001 numbers
Test #7:
score: 0
Accepted
time: 210ms
memory: 3692kb
input:
4991 1000 39678 1249 54437 46017 45224 70229 17603 34864 29604 94448 85430 12263 55898 14782 85335 5653 87061 43854 64868 7691 89219 13493 36702 86976 59640 93900 95498 13230 31210 90574 51152 91506 21366 27131 6431 61743 75930 9336 44487 87340 70841 92525 2237 10001 35034 39269 15226 49198 30121 79...
output:
251570351 251589172 251538274 251520847 251547567 251518079 251492735 251519194 251505737 251483325 251462868 251443905 251469527 251466065 251440294 251390410 251368713 251377575 251395027 251339405 251359785 251351536 251300033 251339703 251323391 251335851 251351155 251372302 251421798 251435651 ...
result:
ok 1001 numbers
Test #8:
score: 0
Accepted
time: 210ms
memory: 3756kb
input:
4992 1000 18454 5936 5721 80172 82110 63373 77346 34954 88742 64771 33347 84178 3457 12800 58088 93594 34839 51363 39251 21548 32131 7715 94267 68584 26806 70022 14280 98625 74643 59979 13048 58940 75633 14369 63838 45140 61340 75117 68541 45528 56117 72040 93777 67915 20397 60895 34278 96484 37454 ...
output:
249618219 249654234 249683165 249682436 249677245 249628244 249704005 249718772 249748178 249768835 249796157 249823793 249843763 249886481 249909282 249917273 249905042 249881567 249839421 249856597 249875790 249876920 249906243 249961596 249989304 249974693 250004114 250012548 249987610 249979537 ...
result:
ok 1001 numbers
Test #9:
score: 0
Accepted
time: 210ms
memory: 3952kb
input:
4993 1000 88719 77920 22413 47032 86292 23812 80194 35044 58279 59286 81264 31900 7911 43522 22329 57342 82616 26169 80931 68109 75043 69232 86424 82897 26676 89248 91846 8212 50779 18984 16161 93669 73004 1607 29756 85433 55263 16706 2996 79525 49904 86148 85317 58533 16160 41305 53330 19577 3570 8...
output:
246937375 246902933 246853357 246792693 246780301 246751075 246825290 246808981 246757941 246700396 246689981 246659903 246680998 246686398 246683731 246711512 246674588 246685355 246694572 246685122 246702201 246726695 246773376 246786648 246799704 246842226 246836993 246822308 246882236 246863694 ...
result:
ok 1001 numbers
Test #10:
score: 0
Accepted
time: 214ms
memory: 3752kb
input:
4994 1000 67496 74095 73697 13891 57771 51548 7233 67839 84712 29609 53373 3815 55469 41540 19273 53795 38906 33678 79506 81966 61060 63453 35477 40313 26547 75771 77925 50503 94211 53796 78057 28399 3079 21548 19867 34238 40673 15191 37450 70418 10988 41471 9561 92255 68819 87122 96574 66862 35094 ...
output:
250146657 250191612 250195029 250208340 250228083 250219002 250250939 250219227 250218163 250182743 250167412 250166327 250166020 250164878 250209768 250195909 250220011 250240657 250222778 250205951 250238241 250204887 250258586 250265300 250301197 250314111 250293524 250350986 250335842 250379917 ...
result:
ok 1001 numbers
Test #11:
score: 0
Accepted
time: 215ms
memory: 3756kb
input:
4995 1000 46273 46078 14581 48047 94657 44692 66977 67929 54249 91420 1290 84241 35731 72262 59322 41735 86684 16995 21185 95823 71268 24970 93042 87329 2225 19189 88195 60090 70348 55905 48465 63129 65858 76082 77274 74530 58788 13676 4608 4414 4775 55579 33805 82873 97285 236 15626 22659 42427 614...
output:
249123929 249093890 249059513 249098346 249091966 249074062 249112865 249070493 249136701 249170937 249165833 249145343 249113654 249135553 249132265 249084428 249044429 249077502 249092360 249059652 249050111 249036494 249017935 249049640 249058877 249093975 249096337 249071045 249068168 249051003 ...
result:
ok 1001 numbers
Test #12:
score: 0
Accepted
time: 214ms
memory: 3684kb
input:
4996 1000 16538 42254 98569 82202 98839 5131 26721 43827 80683 94447 49207 88859 74778 2984 56267 5484 34461 24505 95568 42384 81476 19191 17903 44746 2095 38415 74274 10893 13780 90718 43065 30563 63229 63319 10488 90631 52710 46753 39063 62603 65859 2390 92641 73491 49944 80646 34677 37240 8543 87...
output:
248960238 248974054 248942836 248973067 249005101 249032200 249070300 249023442 249014743 249040593 248989635 249009916 249027265 249058576 249072632 249119208 249134856 249110250 249119365 249101880 249118578 249135024 249129082 249112553 249097813 249099441 249075722 249122221 249167209 249124563 ...
result:
ok 1001 numbers
Test #13:
score: 0
Accepted
time: 214ms
memory: 3744kb
input:
4997 1000 95314 14237 82557 92165 70317 98275 62272 76621 50220 56258 29828 36582 55040 1002 53212 69232 25343 32014 69952 56241 196 46116 34252 59058 69261 57641 84544 20480 89916 84315 13473 32588 93304 83261 67895 30924 38121 21046 73517 20792 51135 49202 16885 31405 78411 26463 10625 17230 15875...
output:
248626297 248613939 248567045 248594344 248588529 248587231 248571746 248596543 248570088 248573785 248581628 248586152 248578111 248555444 248557689 248551497 248566226 248600610 248636341 248624337 248597114 248596593 248618465 248659598 248710238 248648153 248637681 248620564 248636262 248652238 ...
result:
ok 1001 numbers
Test #14:
score: 0
Accepted
time: 214ms
memory: 3684kb
input:
4998 1000 41387 10412 66545 59025 7204 34522 89312 76712 76653 26581 77745 84304 59494 31724 93260 89877 73121 6819 44335 2802 10405 7634 91817 81882 69132 1059 70623 30067 645 19128 75369 22 23378 70498 58006 47025 56235 19531 40676 54789 12218 96014 41129 22023 31069 15385 96973 7619 81992 40146 8...
output:
248167056 248170683 248161396 248134284 248108135 248131832 248080090 248110775 248064774 248033559 248022206 248052437 248031002 248079532 248091063 248135564 248167430 248219697 248262214 248272959 248273463 248270090 248273632 248257206 248234046 248274987 248277803 248294237 248340004 248353679 ...
result:
ok 1001 numbers
Test #15:
score: 0
Accepted
time: 214ms
memory: 3740kb
input:
4999 1000 44356 15100 83237 93180 11386 94962 49056 44098 3086 96904 49854 56219 7052 29742 90205 53625 53603 22840 10206 16659 20613 1855 16677 63491 69002 87581 48189 48166 76781 53940 78481 58944 20749 90440 91220 87317 17454 52608 99322 12977 73302 42825 99965 55745 83728 28499 48729 87608 89324...
output:
249659526 249669312 249691503 249687933 249735478 249694821 249641458 249636823 249619568 249661165 249717066 249762849 249817230 249843562 249865872 249832944 249833793 249831858 249838575 249825250 249783234 249793875 249829814 249789169 249771971 249736711 249750218 249710441 249729641 249701702 ...
result:
ok 1001 numbers
Test #16:
score: -100
Time Limit Exceeded
input:
99990 100000 8407 13171 34685 59100 61849 69684 27699 69734 15978 26396 67189 48485 92204 59033 29990 22522 58882 34685 80298 84456 15797 82715 78860 25748 96625 15087 36123 619 67877 30227 59945 31836 7463 67915 7979 11738 95566 22650 71867 9819 21942 63371 77017 37019 57183 61513 79366 34554 78286...