QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#647098 | #8354. T2 | songziyan | 13 | 877ms | 91616kb | C++14 | 1.2kb | 2024-10-17 11:40:39 | 2024-10-17 11:40:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
char buf[1<<22],*p1,*p2;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1==p2)?0:*p1++)
inline int read(){
int x=0,f=1;char ch=getchar();
while(!isdigit(ch))f=(ch=='-')?-1:1,ch=getchar();
while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return x*f;
}
const int N=2e6+5;
int n,K,q,B,op[5005],x[5005],ans[5005],f[N],g[N],p[N],v[N],t[N],vis[N];
void add1(int i){for(int j=K;j>=t[i];j--)f[j]=max(f[j],f[j-t[i]]+v[i]);}
void add2(int i){for(int j=K/p[i];j>=v[i];j--)g[j]=min(g[j],g[j-v[i]]+t[i]);}
signed main(){
n=read();q=read();K=read();B=sqrt(n+q);
for(int i=1;i<=n;i++)p[i]=read(),v[i]=read(),t[i]=p[i]*v[i];
for(int i=1;i<=q;i++)op[i]=read(),x[i]=read(),vis[x[i]]=op[i]==1;
memset(g,0x3f,sizeof(g));g[0]=0;
for(int i=1;i<=n;i++)if(!vis[i]){if(p[i]<=B)add1(i);else add2(i);}
for(int i=q;i>=1;i--)
if(op[i]==1){if(p[x[i]]<=B)add1(x[i]);else add2(x[i]);}
else{int &res=ans[i];for(int j=x[i]/B;j>=0;j--)if(x[i]>=g[j])res=max(res,f[x[i]-g[j]]+j);}
for(int i=1;i<=q;i++)if(op[i]==2)printf("%lld\n",ans[i]);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 26628kb
input:
3205 5000 5000 1 1 2 1 3 1 7 1 8 1 9 1 10 1 11 1 12 2 13 1 14 2 16 1 17 2 20 3 22 1 24 1 26 2 27 1 30 1 32 2 33 1 34 1 41 1 44 2 49 2 51 1 54 2 58 2 61 2 65 2 66 1 68 2 70 1 71 2 72 2 74 8 75 3 76 5 77 1 78 7 79 5 80 5 81 1 82 2 84 1 86 6 87 6 88 3 89 9 90 5 91 1 92 2 93 3 95 7 96 2 97 2 98 8 99 8 1...
output:
85 73 35 44 46 95 35 87 47 54 96 74 57 70 86 54 72 63 91 42 71 74 84 49 54 69 92 47 40 79 32 67 77 7 57 61 79 21 47 54 50 39 78 59 33 46 82 79 51 84 70 91 39 23 78 25 92 41 72 57 61 29 50 63 60 73 30 89 28 45 68 63 38 65 6 46 38 79 67 58 91 77 88 63 43 41 49 52 94 73 66 25 86 88 34 89 61 92 85 84 70...
result:
wrong answer 1st lines differ - expected: '81', found: '85'
Subtask #2:
score: 13
Accepted
Test #11:
score: 13
Accepted
time: 869ms
memory: 77904kb
input:
1277351 1 2000000 2 2 5 1 7 3 8 4 10 1 12 1 15 2 16 1 18 1 22 1 25 1 28 3 29 1 32 1 35 1 36 1 38 2 40 1 41 2 42 1 43 2 44 2 45 1 48 1 49 1 50 2 54 2 55 2 56 1 58 2 59 2 60 2 62 1 66 1 68 3 69 1 70 3 72 2 76 1 78 1 79 2 81 2 82 3 84 2 85 1 86 2 89 1 90 2 91 2 92 1 93 1 96 3 98 3 99 2 100 3 101 1 102 ...
output:
1771
result:
ok single line: '1771'
Test #12:
score: 13
Accepted
time: 286ms
memory: 78544kb
input:
1276072 1 2000000 48 555 69 189 138 916 164 856 170 174 189 850 197 1043 211 907 218 121 237 183 238 2498 240 94 253 841 261 990 263 593 292 356 295 1018 324 576 328 1364 333 1133 344 16 350 1777 361 225 364 102 371 130 373 956 377 22 387 318 394 1020 395 78 398 445 402 1076 408 43 409 654 411 1143 ...
output:
5128
result:
ok single line: '5128'
Test #13:
score: 13
Accepted
time: 756ms
memory: 78900kb
input:
1287842 1 2000000 2 1 4 1 5 1 12 2 15 1 16 2 17 1 18 1 20 1 21 1 24 3 25 1 27 3 32 1 33 3 36 3 38 1 39 1 40 1 42 2 43 1 44 2 47 1 49 2 50 1 51 1 53 1 54 2 55 1 56 1 57 1 58 1 59 1 61 3 66 1 71 1 72 1 73 1 77 2 79 1 80 1 81 2 82 1 83 1 84 1 86 2 87 2 88 2 93 1 94 1 96 2 97 1 98 2 99 2 100 1 102 1 103...
output:
1563
result:
ok single line: '1563'
Test #14:
score: 13
Accepted
time: 513ms
memory: 75848kb
input:
1287726 1 2000000 31 2304 38 1844 59 7080 66 935 69 790 91 2467 96 6595 100 187 113 2983 118 11250 119 2531 123 1634 129 3513 131 2806 132 9065 133 6537 139 8785 141 2432 144 185 162 2736 173 5683 176 710 181 3468 189 2900 191 5380 193 2120 194 1482 195 3129 202 189 203 1295 207 31 209 1308 211 3118...
output:
2527
result:
ok single line: '2527'
Test #15:
score: 13
Accepted
time: 251ms
memory: 78552kb
input:
1275261 1 2000000 261 1 282 1 289 1 315 2 322 1 323 1 325 1 329 2 330 1 333 3 334 1 336 1 339 1 354 1 363 2 382 2 384 3 385 2 408 1 409 2 412 1 437 1 438 1 449 2 457 1 469 1 471 1 473 1 487 4 505 2 517 1 520 1 525 1 526 1 528 1 531 1 533 1 541 1 548 1 549 1 552 1 557 3 565 1 566 1 582 1 587 1 593 2 ...
output:
656
result:
ok single line: '656'
Test #16:
score: 13
Accepted
time: 617ms
memory: 78440kb
input:
1277958 1 2000000 41 45762 42 39827 47 7603 49 27415 51 34200 56 20936 67 22930 74 13714 78 8175 81 22953 88 19166 89 14746 90 759 92 6808 97 3985 103 9270 104 3971 105 9870 110 9753 111 4980 112 17645 113 17083 114 15474 115 3342 117 14040 118 13826 122 1633 125 12528 126 4024 128 8819 132 14262 13...
output:
40964
result:
ok single line: '40964'
Test #17:
score: 13
Accepted
time: 245ms
memory: 79052kb
input:
1285514 1 2000000 148 1 164 1 180 3 236 2 255 1 264 2 265 2 281 1 285 2 286 1 295 1 315 2 336 2 343 1 358 1 361 1 368 1 372 1 380 1 394 1 402 1 403 1 419 1 424 2 427 1 434 1 437 1 449 1 451 2 457 1 464 1 467 5 473 1 476 1 479 1 484 1 494 1 496 1 503 1 525 1 526 2 538 1 542 1 545 1 547 1 551 1 562 2 ...
output:
1326
result:
ok single line: '1326'
Test #18:
score: 13
Accepted
time: 297ms
memory: 76148kb
input:
1285483 1 2000000 132 11882 175 10006 187 5406 193 2944 205 178 225 7158 245 7573 246 6539 270 5092 273 5858 279 2050 287 5157 293 5816 297 180 299 195 303 3886 309 4296 312 4111 314 2781 322 3666 324 741 335 1477 336 2217 337 1536 341 24 345 4958 346 719 347 1204 375 2312 377 1269 381 4655 388 892 ...
output:
1
result:
ok single line: '1'
Test #19:
score: 13
Accepted
time: 9ms
memory: 33976kb
input:
166661 1 2000000 500003 3 500004 3 500005 3 500006 3 500007 3 500008 3 500009 3 500010 3 500011 3 500012 3 500013 3 500014 3 500015 3 500016 3 500017 3 500018 3 500019 3 500020 3 500021 3 500022 3 500023 3 500024 3 500025 3 500026 3 500027 3 500028 3 500029 3 500030 3 500031 3 500032 3 500033 3 5000...
output:
3
result:
ok single line: '3'
Test #20:
score: 13
Accepted
time: 0ms
memory: 29128kb
input:
66662 1 2000000 333336 4 333337 4 333338 5 333339 5 333340 5 333341 5 333342 4 333343 4 333344 5 333345 5 333346 5 333347 5 333348 5 333349 4 333350 4 333351 5 333352 4 333353 5 333354 5 333355 4 333356 5 333357 5 333358 4 333359 4 333360 4 333361 4 333362 5 333363 5 333364 5 333365 4 333366 4 33336...
output:
5
result:
ok single line: '5'
Subtask #3:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 101ms
memory: 58000kb
input:
5000 5000 2000000 1 1 2 1 3 1 4 1 6 1 7 1 8 1 9 1 10 1 11 1 14 1 15 3 17 2 18 2 21 1 22 1 24 1 25 3 27 1 28 2 29 1 30 1 31 1 32 1 33 1 34 1 35 1 37 1 38 1 39 1 40 2 41 2 43 1 45 1 47 1 49 1 50 1 51 1 54 1 55 1 56 1 61 1 62 2 64 1 65 1 67 2 68 2 70 2 72 2 74 1 76 3 79 2 82 4 83 2 84 1 88 1 91 1 92 1 ...
output:
1715 591 934 692 980 1738 704 1449 1603 466 1645 1478 1322 1341 1033 1641 770 1305 1728 1718 819 949 1655 1609 1676 1311 1445 1365 812 1397 1523 1501 969 164 1722 1722 1393 1415 625 1515 972 1268 1718 892 936 391 1507 901 1257 1279 1083 1291 1337 1718 386 1598 461 568 1658 1672 1650 1060 1541 473 15...
result:
wrong answer 1st lines differ - expected: '1778', found: '1715'
Subtask #4:
score: 0
Wrong Answer
Test #31:
score: 21
Accepted
time: 51ms
memory: 39312kb
input:
191299 5000 300000 1 1 5 1 6 2 7 1 8 1 10 1 11 2 12 2 17 1 18 1 19 1 20 1 21 1 22 2 25 1 28 1 29 2 30 1 31 2 34 1 36 1 37 1 38 1 40 1 42 1 43 1 44 1 45 1 47 2 48 1 51 1 53 3 54 2 56 2 58 2 59 2 61 2 63 4 64 2 67 1 68 2 69 2 70 1 72 1 76 1 77 1 78 1 80 2 83 1 84 1 87 1 88 1 89 1 91 2 93 1 95 1 96 1 9...
output:
221 531 204 303 706 486 663 481 540 430 356 588 407 521 570 547 403 316 279 618 128 431 492 453 578 427 643 430 569 233 98 439 698 621 647 549 567 299 627 227 365 338 433 306 547 286 631 581 574 629 667 451 680 140 273 682 607 302 323 697 193 613 557 523 517 702 544 570 355 542 390 196 260 430 296 6...
result:
ok 2476 lines
Test #32:
score: 21
Accepted
time: 45ms
memory: 40784kb
input:
191816 5000 300000 1 74901 2 103360 3 89547 4 67750 5 40186 6 28389 7 24182 8 26076 9 5630 10 26706 11 12730 12 17632 13 7414 14 15422 15 8901 16 10990 17 1835 18 9986 19 10576 20 7349 21 9585 22 730 23 11619 24 955 25 9845 26 10221 27 4553 28 6352 29 543 30 6193 31 8335 32 8880 33 7372 34 2859 35 6...
output:
75673 84156 84079 75931 76804 88017 83643 5724 2566 82368 80605 7466 74 13141 772 25882 19136 28 15335 983 13151 1903 1027 15836 13179 9720 8449 8462 957 6586 41 8812 6679 9142 17162 8172 27 961 8398 6405 1778 93 8437 6931 16952 7357 97 17663 5778 16433 11220 13273 1001 5088 2947 7747 6358 7577 802 ...
result:
ok 976 lines
Test #33:
score: 21
Accepted
time: 18ms
memory: 39000kb
input:
193270 5000 300000 22 1 29 1 33 1 40 1 43 1 62 1 63 1 64 1 78 1 80 1 94 1 105 1 106 1 108 1 110 2 120 1 128 1 149 1 203 1 207 1 212 1 234 1 255 2 263 1 266 1 286 1 298 1 300 1 302 1 304 1 313 1 314 2 317 1 327 1 353 1 380 1 384 2 403 1 408 1 426 1 428 1 434 1 442 1 472 1 473 1 476 1 477 1 479 1 490 ...
output:
174 412 199 206 181 217 467 139 18 435 483 412 569 114 317 494 256 149 235 292 371 311 293 565 65 390 528 499 502 338 430 532 36 276 276 123 406 466 151 566 294 498 433 423 228 426 225 474 311 340 91 407 16 59 114 557 56 153 78 415 445 168 531 219 228 395 540 401 212 485 88 549 547 527 146 454 300 1...
result:
ok 4004 lines
Test #34:
score: 0
Wrong Answer
time: 53ms
memory: 40460kb
input:
193095 5000 300000 1 94614 2 123167 3 21362 4 23872 5 16365 6 35594 7 38193 8 7725 9 22330 10 19540 11 5255 12 13478 13 5510 14 6237 15 13251 16 14905 17 1701 18 6700 19 8176 20 10001 21 7572 22 8916 23 10170 24 8570 25 10033 26 7465 27 7099 28 6107 29 8603 30 3776 31 4112 32 4161 33 8181 34 7604 35...
output:
115981 21392 153 1922 2252 134582 94628 155 132469 116186 116104 134576 116221 123833 134594 134175 2358 94782 125418 35909 37321 235 24743 315 26345 35805 24310 16599 25819 24747 37300 125184 29515 21620 2369 18595 35825 123844 123194 24095 8250 1868 19545 10465 8379 13456 7948 15094 13988 15871 22...
result:
wrong answer 366th lines differ - expected: '6618', found: '7128'
Subtask #5:
score: 0
Wrong Answer
Test #41:
score: 40
Accepted
time: 364ms
memory: 89424kb
input:
1278949 5000 2000000 4 1 9 1 12 1 13 1 15 2 20 1 21 2 26 1 36 1 39 2 43 1 46 2 59 1 64 1 66 1 71 1 73 1 75 1 78 2 83 1 87 1 89 1 92 1 97 1 103 1 104 1 108 1 111 1 113 1 114 1 117 2 118 1 130 1 137 1 140 1 151 1 152 1 155 1 158 2 163 1 164 1 165 1 168 1 172 1 173 1 183 1 185 1 186 1 192 1 208 1 210 2...
output:
272 361 1207 742 550 255 1305 781 1061 187 1354 262 448 426 1379 1246 1278 390 964 1243 1483 529 1150 545 1016 713 844 469 570 1353 426 995 1175 1390 1181 655 1294 538 906 572 415 1064 1276 1234 839 747 367 1135 621 363 1457 663 465 402 1146 1359 734 1093 527 1412 929 476 383 1463 344 1062 1456 452 ...
result:
ok 2474 lines
Test #42:
score: 40
Accepted
time: 809ms
memory: 91444kb
input:
1278613 5000 2000000 1 1222462 2 456727 3 334990 4 330207 5 222769 6 52941 7 247811 8 131230 9 73420 10 187657 11 45883 12 121991 13 31509 14 94454 15 21739 16 118643 17 67978 18 22774 19 24405 20 4442 21 74797 22 10974 23 8219 24 11261 25 4112 26 39242 27 62294 28 71371 29 10931 30 53060 31 54203 3...
output:
12748 339473 103346 5489 66071 428436 423963 66210 64361 11415 339882 389422 74917 356757 21838 11384 417488 417362 414504 73489 86180 1493 69388 103532 11014 89566 72 66398 30369 5557 63335 84808 32743 66775 46224 4911 46588 1417 46777 4515 22110 30664 30373 51673 7466 23283 72609 27770 66637 76758...
result:
ok 1002 lines
Test #43:
score: 40
Accepted
time: 877ms
memory: 91276kb
input:
1288475 5000 2000000 2 2 3 1 5 1 6 2 7 1 9 1 12 1 13 1 18 2 19 3 20 1 23 3 25 2 29 1 30 1 31 2 34 1 35 1 36 1 37 1 39 2 41 3 43 2 45 2 46 1 48 2 49 1 51 1 54 2 57 3 58 2 60 3 62 3 63 1 65 3 67 1 68 1 69 1 71 1 72 1 74 1 75 1 76 1 77 2 78 1 79 1 81 1 82 1 83 1 87 1 88 1 89 1 91 1 94 1 95 1 96 2 98 1 ...
output:
1531 1083 1804 2011 1978 1853 2031 1788 1414 1669 1580 1716 798 1415 1906 971 1261 893 207 1697 658 1221 1628 1702 1419 572 1144 1734 1521 1990 687 723 624 1028 1578 1603 1143 811 1118 1631 841 528 1474 1792 728 1267 1596 947 1691 1481 1881 591 1547 1407 1514 1670 1152 1210 596 727 1852 1476 1227 19...
result:
ok 3958 lines
Test #44:
score: 40
Accepted
time: 835ms
memory: 91616kb
input:
1289902 5000 2000000 1 790084 2 371044 3 436041 4 57717 5 287778 6 75840 7 174763 8 33883 9 132574 10 51288 11 125162 12 124874 13 102798 14 13655 15 123829 16 80061 17 12764 18 101698 19 97315 20 30037 21 28635 22 17819 23 11699 24 37423 25 53442 26 33138 27 45574 28 2138 29 51426 30 24398 31 21696...
output:
1232935 865933 371105 433547 518264 463201 87 539034 539004 506767 91687 429311 76302 371479 71806 465427 538919 95948 60466 96379 371072 520403 541057 94377 552572 442417 71431 373674 223075 14117 133624 181157 2658 245699 185345 93825 199108 245756 149350 200706 219248 60503 235158 4839 220894 147...
result:
ok 2512 lines
Test #45:
score: 0
Wrong Answer
time: 695ms
memory: 91508kb
input:
1278678 5000 2000000 2 1 3 1 5 1 6 1 7 1 10 1 12 1 13 1 14 1 15 1 17 3 18 2 19 1 20 2 25 2 29 1 31 1 35 1 36 2 38 1 45 1 48 3 49 1 56 1 57 1 58 1 60 1 64 1 65 2 66 1 70 2 71 2 72 3 73 1 78 1 84 1 86 1 87 4 88 3 89 1 90 1 94 1 95 1 97 2 98 3 101 1 102 1 105 1 110 3 113 2 116 1 117 1 119 1 120 1 121 1...
output:
564 1227 1176 553 490 694 1534 776 926 1287 1399 883 1621 1542 1283 1299 1316 975 1233 1180 961 879 1748 716 905 660 814 987 244 1481 1025 1520 1304 1100 795 1365 1167 1381 1227 1494 1577 635 1078 887 1266 1279 1242 1344 744 765 1089 667 467 1452 932 1652 1303 1713 973 587 1268 888 1529 1544 1209 14...
result:
wrong answer 913th lines differ - expected: '1394', found: '1376'