QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#108812#5123. StreetsshenxingeAC ✓945ms13736kbC++231.4kb2023-05-26 18:03:382023-05-26 18:03:41

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-26 18:03:41]
  • 评测
  • 测评结果:AC
  • 用时:945ms
  • 内存:13736kb
  • [2023-05-26 18:03:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int maxn(1e5+10),maxe(1e5),inf(1e9+7);
int n,m,T,X[maxn],Y[maxn],A[maxn],B[maxn],va[maxn],vb[maxn],f[maxn][21],st[maxn],top,mx;long long c;
inline long long F(int i,int j){return 1ll*i*vb[j]+1ll*j*va[i];}
inline bool check(int x,int y){
	for(int i=20;i--;) if(f[f[y][i]][0]&&F(x,f[f[y][i]][0])<=F(x,f[y][i])) y=f[y][i];
	if(y^mx&&F(x,f[y][0])<=c) return true; return F(x,y)<=c;
}
signed main(){
	ios::sync_with_stdio(false),cin.tie(nullptr);
	cin >> n >> m >> T;for(int i=1;i<=maxe;i++) va[i]=vb[i]=inf;
	for(int i=1;i<=n;i++) cin >> X[i];for(int i=1;i<=n;i++) cin >> A[i];
	for(int i=1;i<=m;i++) cin >> Y[i];for(int i=1;i<=m;i++) cin >> B[i];
	for(int i=1;i<n;++i) for(int j=i+1;j<=n;++j) va[X[j]-X[i]]=min(va[X[j]-X[i]],A[i]+A[j]);
	for(int i=1;i<m;++i) for(int j=i+1;j<=m;++j) vb[Y[j]-Y[i]]=min(vb[Y[j]-Y[i]],B[i]+B[j]);
	for(int i=maxe;i;i--) if(vb[i]<inf){
		while(top>1&&(vb[st[top]]-vb[i])*1ll*(st[top-1]-st[top])>=(vb[st[top-1]]-vb[st[top]])*1ll*(st[top]-i)) top--;
		if(!top) mx=i; else f[i][0]=st[top]; st[++top]=i;
	}
	for(int i=1;i<20;i++) for(int u=1;u<=maxe;u++) f[u][i]=f[f[u][i-1]][i-1];
	while(T--){cin >> c;long long ans=0;
		for(int i=maxe,p=1;i;i--) if(va[i]!=inf) while(true){
			while(p<=mx&&vb[p]==inf) p++; if(p<=mx&&check(i,p)) ans=max(ans,1ll*i*(p++)); else break;
		}cout << ans << '\n';
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 15ms
memory: 12456kb

input:

3 4 20
1 3 4
3 1 2
1 3 4 7
4 2 1 2
1
5
6
7
9
10
11
12
15
16
17
22
23
28
30
35
43
47
49
57

output:

0
0
1
1
1
2
2
3
3
4
4
6
6
9
9
12
12
12
18
18

result:

ok 20 numbers

Test #2:

score: 0
Accepted
time: 945ms
memory: 12540kb

input:

4995 4998 100
4 7 20 34 44 100 102 130 175 198 205 250 257 259 267 278 300 324 337 346 353 364 403 427 439 440 451 523 532 534 555 599 634 639 756 802 805 825 855 859 890 905 912 915 953 989 1014 1031 1052 1059 1097 1124 1183 1216 1297 1308 1337 1342 1361 1392 1400 1421 1451 1471 1523 1537 1542 1619...

output:

9991201920
9941157660
8387550150
9892186440
9803600290
9986903784
9928424616
9892186440
9831470090
9768930402
9831470090
9058876564
9803600290
9857548260
9944740920
9892186440
9885418060
9831470090
9857548260
9768930402
8671693002
9803600290
9911595765
9058876564
9803600290
9838238470
9024072106
980...

result:

ok 100 numbers

Test #3:

score: 0
Accepted
time: 901ms
memory: 12460kb

input:

4995 4996 100
72 80 119 144 216 272 283 292 300 313 317 332 337 338 369 374 416 422 447 480 506 535 571 581 590 592 604 614 622 639 676 677 691 695 700 723 739 742 748 755 779 787 797 839 847 856 864 878 886 888 890 894 898 899 904 1007 1023 1049 1051 1061 1070 1122 1125 1153 1168 1187 1190 1225 124...

output:

9985005184
9855576720
9855576720
6122924640
9437544131
9627630660
9951648960
9627630660
9635613716
9855576720
9855576720
9627630660
9936899280
9960518700
9254863411
9855576720
9936899280
9974416128
9941882280
7314670570
9984905280
9254274235
9818294436
9855576720
9945769020
9985005184
9855576720
981...

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 784ms
memory: 13636kb

input:

4999 4998 100
24 28 58 91 107 122 129 134 137 166 200 216 248 266 329 336 362 389 392 399 404 419 547 557 564 573 642 680 682 720 727 728 824 826 853 861 865 897 901 902 908 911 932 953 956 962 977 982 997 1002 1022 1025 1035 1062 1068 1085 1120 1168 1172 1192 1198 1205 1274 1294 1371 1372 1373 1410...

output:

9991701692
9253373820
9755390874
9968222577
9377310990
9829353624
9804851874
8890538665
9949256772
9253373820
9110273475
9377310990
8890538665
9794940174
9962335026
9444281184
9514977448
9708304002
9110273475
9377310990
8890538665
9253373820
9175336560
9664890422
6123991927
9621153720
9377310990
988...

result:

ok 100 numbers

Test #5:

score: 0
Accepted
time: 819ms
memory: 12628kb

input:

4995 4999 100
15 43 47 59 95 107 176 180 264 328 338 362 367 369 373 391 428 484 502 550 573 577 596 614 621 628 649 676 678 702 705 715 748 755 764 779 800 805 842 846 854 858 888 909 928 946 998 1018 1036 1082 1084 1087 1093 1102 1113 1120 1128 1137 1160 1164 1173 1200 1241 1251 1260 1269 1298 130...

output:

9990601368
9839407611
9955914580
9634428612
9910930780
9843029676
9790830072
9790830072
9821886558
9921626928
7879145340
9944418720
9929496720
9987203312
9895336396
9880488046
9843029676
9821886558
9928824336
7899488010
9821886558
9910930780
9821886558
9988802736
9854913855
9929496720
9889812895
966...

result:

ok 100 numbers

Test #6:

score: 0
Accepted
time: 872ms
memory: 13204kb

input:

4997 4999 100
45 46 51 93 99 135 140 144 186 189 206 229 231 232 246 251 267 275 297 364 395 466 474 486 489 504 558 559 571 591 599 623 632 645 646 732 740 749 753 780 781 870 904 920 954 956 971 983 984 1010 1022 1040 1045 1085 1108 1122 1129 1164 1210 1215 1243 1245 1262 1307 1317 1371 1425 1472 ...

output:

9989602700
8899349230
9798172153
9798172153
9905126028
9481804741
9798172153
9687737143
9595807459
9905126028
9671520110
9905126028
9798172153
9809016672
9706242469
9900946356
9938085284
9798172153
9798172153
1563896
8998119272
8899349230
9798172153
9942765826
9595807459
9931099704
9931099704
990512...

result:

ok 100 numbers

Test #7:

score: 0
Accepted
time: 865ms
memory: 13320kb

input:

4998 4999 100
15 16 27 35 48 49 58 69 104 110 137 187 203 219 306 338 349 362 382 429 465 475 477 548 549 586 631 674 691 712 730 794 813 831 859 874 953 975 981 988 994 1027 1034 1048 1075 1084 1106 1108 1127 1134 1138 1140 1194 1223 1231 1237 1243 1252 1312 1337 1340 1343 1351 1359 1373 1419 1444 ...

output:

9987202871
322360992
34221228
170018460
2077200000
367788248
1849331484
104562900
130121250
667780755
14502428
199090845
70810920
229443360
34962225
732300000
593392380
465415095
179545680
11473369
765100000
952200000
10389199
489931907
1478004636
95030900
377990696
144950880
621853944
400045988
820...

result:

ok 100 numbers

Test #8:

score: 0
Accepted
time: 835ms
memory: 13624kb

input:

5000 4998 100
12 48 62 74 84 89 101 112 113 124 144 152 174 192 206 226 239 251 255 266 275 324 350 360 371 392 418 426 442 477 478 517 519 523 548 574 608 611 630 636 657 713 741 743 761 767 782 791 835 866 887 891 894 920 921 949 990 991 1014 1023 1027 1052 1160 1242 1292 1293 1300 1316 1336 1339 ...

output:

9991401845
72048782
238228310
4282764528
1064534064
2881940
199786720
47505248
231842464
30432900
438353664
346126284
228224010
172523728
627411081
58729986
345070614
17939856
432229174
50864068
50807316
632177952
145521558
579973554
390817644
411876612
222499242
1189371222
266040280
80569600
179062...

result:

ok 100 numbers

Test #9:

score: 0
Accepted
time: 762ms
memory: 13120kb

input:

4998 5000 100
23 25 54 99 131 150 166 203 234 235 272 288 294 318 346 360 387 396 402 406 409 433 435 477 506 533 553 571 586 611 620 626 727 749 751 783 808 817 849 890 894 949 970 1037 1062 1149 1150 1174 1175 1233 1258 1278 1279 1290 1316 1342 1345 1348 1357 1371 1443 1464 1469 1498 1510 1537 155...

output:

9993201107
27375576
302873295
452991816
529291971
304218249
141983101
100676951
232936990
115904674
40322016
220520727
264995672
595711164
32434083
419780835
104958141
102793198
312550544
453456414
418280694
33955446
687323223
152486865
642988224
46236976
28363572
107850270
247333179
9993201107
9559...

result:

ok 100 numbers

Test #10:

score: 0
Accepted
time: 776ms
memory: 12596kb

input:

5000 4995 100
6 12 42 43 44 52 76 77 114 128 169 184 200 208 227 228 257 300 301 315 369 425 434 450 460 485 509 576 584 596 616 629 667 668 682 695 743 783 790 818 835 847 932 959 968 972 979 984 1029 1054 1066 1084 1087 1088 1128 1146 1165 1167 1187 1281 1312 1351 1361 1365 1374 1381 1422 1423 144...

output:

9996800247
258580312
24122062
1709133632
27666573
1377488800
356523432
2030864014
40363470
6590047653
4605893064
262508512
20977412
60813312
5790099672
381663912
502914352
97038123
191298750
292938968
912756552
218996782
388944176
3762848968
1222298712
356523432
204585952
3661968
175407224
97920440
...

result:

ok 100 numbers

Test #11:

score: 0
Accepted
time: 789ms
memory: 12892kb

input:

4996 4995 100
27 39 75 76 90 114 115 117 149 150 168 198 210 216 289 335 346 351 368 393 405 415 441 512 518 528 529 542 545 569 570 595 646 685 693 697 698 709 731 752 788 827 837 841 852 860 891 905 926 927 949 1006 1015 1016 1025 1056 1085 1091 1238 1239 1253 1257 1261 1286 1296 1305 1313 1317 13...

output:

9992801292
300232845
32019138
130119308
9992801292
285304140
11363643
6598410
358214325
8391445938
169932208
197541450
710093655
238745232
520494075
931058595
2239104690
449017245
87762690
4225577490
96609330
455685870
1083763665
58662614
259956675
82470297
259941132
426347730
20272918
8027740
26818...

result:

ok 100 numbers

Test #12:

score: 0
Accepted
time: 160ms
memory: 12436kb

input:

4996 4996 100
20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360...

output:

9980010000
760088000
3023575200
281808000
1234819600
410009600
217322400
621264800
723610000
835284000
362328000
2622528000
660528000
636524000
3902500800
1376619200
528280000
476504800
574320800
711984000
2114912000
511116000
2212761600
507006000
3234144000
1159293600
693680000
644066000
3025343200...

result:

ok 100 numbers

Test #13:

score: 0
Accepted
time: 162ms
memory: 13164kb

input:

5000 4996 100
20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360...

output:

9988002000
705414000
564904000
717552000
179527600
79883600
157262400
604074000
995624000
992880000
1257411600
39972800
666402000
255302800
256538000
1740532800
1677702000
405188000
520522000
364428000
1120900400
622105600
1322798800
7409766400
470505600
1923488000
752742000
350188400
6611131200
699...

result:

ok 100 numbers

Test #14:

score: 0
Accepted
time: 158ms
memory: 13736kb

input:

4995 5000 100
20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360...

output:

9986002400
822052400
595360000
433312400
362419200
1138027600
3089967200
658896000
663616800
111916800
616106400
5541313600
843145200
1104782000
676397600
560566000
311827200
525859200
626220000
76562400
1868356800
5518656000
2601000000
767707200
1123128000
903056000
2097409600
475603200
1559641600
...

result:

ok 100 numbers

Test #15:

score: 0
Accepted
time: 169ms
memory: 12452kb

input:

4999 4995 100
20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360...

output:

9984004800
4104616800
2185651200
801752000
2883050000
646128000
945687600
508760000
602305600
525784800
587307200
1092968800
1087040400
891740800
429954000
651768800
975726000
312388800
1511709600
866483200
4631803600
9842624000
431172000
676044000
1449478000
416134400
459900000
667296000
5580032400...

result:

ok 100 numbers