QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#55059 | #2281. BnPC | MIT01# | WA | 115ms | 15316kb | C++ | 1.6kb | 2022-10-12 07:57:32 | 2022-10-12 07:57:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll scores[100005];
int freq[100005];
ll frst[100005];
int attr[100005];
ll threshold[100005];
ll spend;
int n, m;
int get_attr() {
static map<string, int> id;
char buf[26];
scanf("%s", buf);
string s(buf);
auto it = id.find(s);
if (it != id.end())
return it->second;
int l = id.size();
id[s] = l;
return l;
}
int main() {
scanf("%d%lld", &n, &spend);
for (int i = 0; i < n; i++) {
int a = get_attr();
scanf("%lld", scores+i);
}
scanf("%d", &m);
for (int i = 0; i < m; i++) {
attr[i] = get_attr();
scanf("%lld", threshold+i);
}
// make sure we don't die
for (int i = 0; i < m; i++) {
if (scores[attr[i]] < threshold[i]) {
ll diff = threshold[i] - scores[attr[i]];
spend -= diff;
scores[attr[i]] += diff;
}
}
if (spend < 0) {
printf("0\n");
return 0;
}
// get current score
ll ans = 0;
for (int i = 0; i < m; i++)
if (threshold[i] < scores[attr[i]])
ans += scores[attr[i]];
// spend extra
for (int i = 0; i < m; i++) {
freq[attr[i]]++;
if (threshold[i] == scores[attr[i]]) {
frst[attr[i]]++;
}
}
ll gradient = 0;
for (int i = 0; i < n; i++)
gradient = max(gradient, (ll)freq[attr[i]]);
vector<ll> alt;
for (int i = 0; i < n; i++) {
alt.push_back(frst[i] * scores[i] + freq[i]);
}
sort(alt.begin(), alt.end(), greater<ll>());
for (ll u: alt)
if (u > gradient && spend > 0) {
spend--;
ans += u;
}
ans += spend * gradient;
printf("%lld\n", ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3828kb
input:
3 14 THISISTHEONE 8 B 0 C 0 8 THISISTHEONE 10 C 0 B 1 B 0 THISISTHEONE 0 C 1 THISISTHEONE 0 THISISTHEONE 0
output:
82
result:
ok single line: '82'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
3 99 THEFIRSTINCREASE 6 SECONDINCREASE 4 ZZZ 1 9 THEFIRSTINCREASE 4 ZZZ 0 THEFIRSTINCREASE 6 SECONDINCREASE 8 THEFIRSTINCREASE 2 SECONDINCREASE 1 ZZZ 0 SECONDINCREASE 8 THEFIRSTINCREASE 3
output:
429
result:
ok single line: '429'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3768kb
input:
5 20 A 100 B 200 C 300 D 400 E 500 949 A 39 A 23 C 163 A 98 B 36 A 3 A 52 B 152 B 167 B 65 C 142 B 66 B 117 C 288 C 155 E 341 A 97 D 173 E 31 A 62 D 90 E 361 A 42 D 85 E 1 C 141 B 77 B 194 D 221 E 203 D 345 E 48 B 26 D 46 B 74 E 380 B 181 C 243 B 112 A 99 E 403 C 20 E 453 C 149 B 26 E 245 A 74 D 304...
output:
285180
result:
ok single line: '285180'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3696kb
input:
2 1 A 10 B 12 3 A 10 B 10 B 10
output:
35
result:
ok single line: '35'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3848kb
input:
1 1 OVERENTHUSIASTICNESS 41 1 OVERENTHUSIASTICNESS 0
output:
42
result:
ok single line: '42'
Test #6:
score: 0
Accepted
time: 103ms
memory: 15216kb
input:
100000 1000000000 A 1000000000 B 1000000000 C 1000000000 D 1000000000 E 1000000000 F 1000000000 G 1000000000 H 1000000000 I 1000000000 J 1000000000 K 1000000000 L 1000000000 M 1000000000 N 1000000000 O 1000000000 P 1000000000 Q 1000000000 R 1000000000 S 1000000000 T 1000000000 U 1000000000 V 1000000...
output:
100007999593560
result:
ok single line: '100007999593560'
Test #7:
score: 0
Accepted
time: 115ms
memory: 15316kb
input:
100000 1000000000 A 1000000000 B 1000000000 C 1000000000 D 1000000000 E 1000000000 F 1000000000 G 1000000000 H 1000000000 I 1000000000 J 1000000000 K 1000000000 L 1000000000 M 1000000000 N 1000000000 O 1000000000 P 1000000000 Q 1000000000 R 1000000000 S 1000000000 T 1000000000 U 1000000000 V 1000000...
output:
100006999854911
result:
ok single line: '100006999854911'
Test #8:
score: 0
Accepted
time: 16ms
memory: 4920kb
input:
1 1000000000 A 1000000000 100000 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0...
output:
200000000000000
result:
ok single line: '200000000000000'
Test #9:
score: 0
Accepted
time: 2ms
memory: 3700kb
input:
1 1 A 0 1 A 0
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
1 800000 A 0 1000 A 0 A 1 A 2 A 3 A 4 A 5 A 6 A 7 A 8 A 9 A 10 A 11 A 12 A 13 A 14 A 15 A 16 A 17 A 18 A 19 A 20 A 21 A 22 A 23 A 24 A 25 A 26 A 27 A 28 A 29 A 30 A 31 A 32 A 33 A 34 A 35 A 36 A 37 A 38 A 39 A 40 A 41 A 42 A 43 A 44 A 45 A 46 A 47 A 48 A 49 A 50 A 51 A 52 A 53 A 54 A 55 A 56 A 57 A ...
output:
800000000
result:
ok single line: '800000000'
Test #11:
score: 0
Accepted
time: 12ms
memory: 4976kb
input:
2 1000000000 B 235 A 1000000000 100000 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A 1 A...
output:
200000000000000
result:
ok single line: '200000000000000'
Test #12:
score: 0
Accepted
time: 53ms
memory: 8784kb
input:
50457 435832308 A 192207613 B 218291430 C 72712030 D 8339557 E 233611631 F 924985735 G 707429015 H 495523396 I 1524253 J 940348426 K 191972642 L 421286578 M 162847048 N 280111507 O 601044189 P 929639718 Q 893573186 R 920586936 S 56283573 T 46461264 U 4612777 V 221232991 W 968811350 X 783669701 Y 667...
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 2ms
memory: 4004kb
input:
2836 44662413 A 269836858 B 972857889 C 51515364 D 328683395 E 526234284 F 689725572 G 769138643 H 790617490 I 48093964 J 243168110 K 180077017 L 623293643 M 981360167 N 645396090 O 412624316 P 709387419 Q 322883776 R 553162583 S 216235922 T 209753908 U 528154246 V 451750020 W 300516519 X 572996665 ...
output:
0
result:
ok single line: '0'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
465 720708570 A 964489218 B 152054233 C 552095349 D 209903032 E 926041026 F 973820240 G 417242347 H 652805464 I 774473005 J 868230713 K 721131727 L 627241636 M 623019960 N 809095709 O 928690803 P 229390175 Q 595062361 R 273163306 S 798525471 T 972932324 U 333873971 V 927559188 W 926041190 X 64539094...
output:
0
result:
ok single line: '0'
Test #15:
score: 0
Accepted
time: 16ms
memory: 4664kb
input:
2658 922279939 A 179440353 B 624882483 C 104338141 D 130390676 E 328696385 F 669528812 G 938956597 H 134386530 I 854249965 J 282808688 K 695715582 L 326559726 M 707578888 N 290880040 O 20090871 P 896530690 Q 236292479 R 782324722 S 233253660 T 916440565 U 285886536 V 430491333 W 48525799 X 868428462...
output:
0
result:
ok single line: '0'
Test #16:
score: 0
Accepted
time: 3ms
memory: 3776kb
input:
8 274740128 A 787142485 B 216348350 C 116587980 D 963101420 E 296609285 F 76881088 G 324055267 H 97255786 4 D 278467507 G 929361476 A 103818943 D 335313499
output:
0
result:
ok single line: '0'
Test #17:
score: 0
Accepted
time: 13ms
memory: 4352kb
input:
355 325155415 A 44833348 B 871233156 C 31992384 D 149027764 E 941973900 F 913862251 G 836954440 H 165707546 I 703453203 J 238029892 K 936849814 L 951092717 M 621542577 N 135251097 O 526232560 P 154173639 Q 812248178 R 360837673 S 29361628 T 912681470 U 848101041 V 790156523 W 543481112 X 227403881 Y...
output:
0
result:
ok single line: '0'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
516 876102983 A 68079588 B 607865472 C 586115560 D 834251151 E 87957637 F 962496410 G 836754794 H 830728526 I 643131807 J 75363697 K 110415934 L 606888382 M 513209012 N 872632048 O 782613088 P 285301268 Q 376901180 R 675751665 S 216874851 T 517125466 U 301946024 V 435754958 W 466322875 X 633407709 Y...
output:
0
result:
ok single line: '0'
Test #19:
score: 0
Accepted
time: 2ms
memory: 3716kb
input:
6 690409537 A 548663356 B 706017338 C 306741866 D 951661376 E 383836924 F 709600248 1702 C 324469538 C 991088537 B 779024449 D 550683338 A 817153008 E 504793649 E 595511588 F 776506465 B 221367140 D 922156232 A 22456728 B 729727714 A 501225234 F 315280769 D 76402244 A 774494518 E 33765301 C 26334577...
output:
0
result:
ok single line: '0'
Test #20:
score: 0
Accepted
time: 25ms
memory: 8724kb
input:
54589 934238577 A 426157661 B 731298047 C 238356016 D 327872720 E 883602635 F 118182006 G 958721654 H 486056423 I 568843934 J 711551424 K 453315009 L 350421124 M 668088075 N 105446842 O 831801452 P 79487681 Q 103675132 R 576395265 S 971309192 T 78045673 U 674894656 V 179462575 W 557585061 X 38900798...
output:
4072850284
result:
ok single line: '4072850284'
Test #21:
score: 0
Accepted
time: 3ms
memory: 3764kb
input:
7 879093735 A 850928522 B 350468065 C 748796252 D 837694952 E 348921976 F 756802752 G 534822329 2052 B 967262777 B 393967428 E 502284363 A 940905594 E 810277410 A 568791040 D 511480180 G 65731261 E 671267678 F 595597916 F 240588953 B 180979922 C 671054842 B 914129862 D 260422699 F 669613469 E 197144...
output:
0
result:
ok single line: '0'
Test #22:
score: 0
Accepted
time: 2ms
memory: 3780kb
input:
6 842299994 A 379167737 B 115169471 C 119285747 D 943499403 E 177449883 F 10220555 1569 B 697422586 C 400884912 C 269415831 E 828123297 B 849064734 E 704245857 E 610386292 B 877095846 D 518961752 C 523904020 C 495900322 C 933105747 C 450242097 A 769402759 E 287913977 C 404068305 E 781388043 D 472512...
output:
0
result:
ok single line: '0'
Test #23:
score: 0
Accepted
time: 69ms
memory: 9852kb
input:
64738 943472339 A 979065476 B 832949548 C 152126332 D 575907209 E 811321449 F 712120870 G 723326799 H 889941752 I 467316971 J 595719757 K 927907719 L 53991523 M 673203943 N 126964655 O 824177390 P 4268947 Q 290023999 R 461758370 S 323213342 T 311180813 U 865360504 V 661904574 W 181180161 X 721973291...
output:
0
result:
ok single line: '0'
Test #24:
score: 0
Accepted
time: 3ms
memory: 3692kb
input:
8 53861228 A 891720756 B 341615418 C 247127721 D 114705614 E 794800619 F 535476057 G 472546264 H 17162179 2164 D 59853020 B 972442325 F 406778948 G 583852826 E 818558037 H 237153728 F 791306889 D 938863078 A 481681370 C 501216450 H 276218794 C 564718804 F 61396156 B 32108808 E 268680596 D 740046589 ...
output:
0
result:
ok single line: '0'
Test #25:
score: 0
Accepted
time: 2ms
memory: 3796kb
input:
7 412675199 A 917821399 B 836089065 C 131844033 D 670963745 E 429723800 F 400355535 G 977010106 1727 F 308538376 B 935247759 D 491075499 C 374071258 A 224676327 E 676481834 G 423340823 D 641914255 B 704683198 A 377398567 G 272649163 C 304228705 G 376493987 G 606275219 F 830823140 B 812720422 F 17191...
output:
0
result:
ok single line: '0'
Test #26:
score: 0
Accepted
time: 39ms
memory: 8716kb
input:
57374 711276406 A 613156442 B 82011174 C 10463444 D 12802565 E 437036386 F 95927948 G 350288062 H 151941178 I 646283948 J 677004796 K 990479171 L 789096157 M 564621747 N 355408210 O 507084367 P 12697544 Q 211495000 R 602910948 S 76342025 T 199206245 U 80989675 V 490978999 W 438227462 X 501156116 Y 7...
output:
0
result:
ok single line: '0'
Test #27:
score: 0
Accepted
time: 3ms
memory: 3764kb
input:
6 332497508 A 711034572 B 407702010 C 568304901 D 659423025 E 316462184 F 367066900 5 A 595718092 E 48734900 D 343645794 D 451342914 A 630129036
output:
3722372394
result:
ok single line: '3722372394'
Test #28:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
1666 451934537 A 342650525 B 91252632 C 298571149 D 817065369 E 853857673 F 81868669 G 422520903 H 322430130 I 196304023 J 456374454 K 927449288 L 497007895 M 929749589 N 545239160 O 535738197 P 64154330 Q 557982713 R 89376619 S 485410593 T 580548727 U 157583689 V 976335802 W 986118132 X 849368305 Y...
output:
0
result:
ok single line: '0'
Test #29:
score: 0
Accepted
time: 5ms
memory: 3836kb
input:
1651 407668104 A 458317692 B 909435400 C 741022991 D 233178625 E 313863379 F 7949477 G 141369403 H 630890074 I 66872471 J 279856115 K 923864992 L 151312340 M 417007154 N 399894770 O 69017739 P 548150733 Q 437095676 R 220116084 S 253200337 T 301479723 U 156710761 V 626785328 W 1882138 X 755509454 Y 2...
output:
0
result:
ok single line: '0'
Test #30:
score: 0
Accepted
time: 95ms
memory: 9068kb
input:
55686 808700322 A 34664429 B 917493539 C 860519058 D 806167135 E 196866799 F 857809984 G 933756527 H 978074492 I 86246168 J 205452256 K 615177430 L 631659858 M 472137097 N 109420732 O 265983334 P 563177753 Q 79568891 R 625998292 S 798618556 T 499423935 U 866419872 V 812223015 W 749984116 X 593584291...
output:
0
result:
ok single line: '0'
Test #31:
score: 0
Accepted
time: 41ms
memory: 8376kb
input:
55068 670749199 A 354429008 B 534732910 C 476171149 D 39980987 E 7922157 F 785200131 G 72923364 H 128554320 I 703066856 J 491260143 K 389319695 L 910861355 M 620520758 N 232407731 O 482501720 P 285917225 Q 871459300 R 897151314 S 856870482 T 581791393 U 255026002 V 257072875 W 527993351 X 5605973 Y ...
output:
0
result:
ok single line: '0'
Test #32:
score: 0
Accepted
time: 7ms
memory: 4412kb
input:
8 1302605 A 134287489 B 573282005 C 300684184 D 837596997 E 827512071 F 582064343 G 494505886 H 541393637 54301 C 585334477 B 41308975 B 937525630 F 904321787 G 784948851 F 249994222 G 282089489 B 555497919 E 118133744 C 19250881 E 996634220 D 807449144 H 366721213 C 803919575 D 77742245 A 939221251...
output:
0
result:
ok single line: '0'
Test #33:
score: 0
Accepted
time: 37ms
memory: 9192kb
input:
65692 141672743 A 879111798 B 208999764 C 219696947 D 335711396 E 994357505 F 841578478 G 650693339 H 131587825 I 800838292 J 50756269 K 226369807 L 250533548 M 700677866 N 979860504 O 20239766 P 652697062 Q 541122563 R 680348402 S 687780120 T 228125455 U 681569920 V 608655539 W 45180496 X 377028083...
output:
0
result:
ok single line: '0'
Test #34:
score: 0
Accepted
time: 2ms
memory: 3652kb
input:
8 937449651 A 132265030 B 466908475 C 536633364 D 333405397 E 446012016 F 189415547 G 97170372 H 511334059 2302 H 274089471 H 720270279 C 320288129 B 54458530 C 556081819 D 138819439 B 703339773 C 88307151 C 497799547 G 503433922 H 734206266 B 87503806 D 823570154 H 149232652 B 206861255 E 878946850...
output:
0
result:
ok single line: '0'
Test #35:
score: 0
Accepted
time: 1ms
memory: 3696kb
input:
1449 10923999 A 663761329 B 98982403 C 98188974 D 801248187 E 815496608 F 469049136 G 431475286 H 664339712 I 216554048 J 406215776 K 244437043 L 241651531 M 632573840 N 274839844 O 581816514 P 957938624 Q 178553700 R 572318284 S 110717151 T 418572568 U 106199122 V 418140358 W 438960064 X 558540062 ...
output:
0
result:
ok single line: '0'
Test #36:
score: 0
Accepted
time: 15ms
memory: 4440kb
input:
7 823300961 A 721849235 B 700707242 C 643102502 D 81447467 E 486710849 F 835244553 G 906828063 56493 E 842344104 G 98591759 A 931741972 A 892916194 G 176433338 B 588709412 A 650523027 D 999189608 A 947818425 B 695834149 A 13889810 D 746695432 F 535129636 D 75253858 C 100428190 B 429077751 B 55665355...
output:
0
result:
ok single line: '0'
Test #37:
score: 0
Accepted
time: 23ms
memory: 4736kb
input:
57 868750896 A 404861638 B 45332195 C 636257002 D 442790255 E 764452001 F 496390941 G 100558829 H 109071496 I 825410260 J 454859111 K 507977989 L 58855441 M 660079869 N 236590656 O 558128363 P 669440808 Q 24054160 R 631971551 S 658443629 T 231980163 U 165402378 V 509899789 W 368656077 X 812803319 Y ...
output:
45058035839168
result:
ok single line: '45058035839168'
Test #38:
score: 0
Accepted
time: 59ms
memory: 12648kb
input:
85565 707071591 A 887733008 B 867938476 C 806988939 D 550192346 E 760098436 F 352438566 G 965215269 H 935667009 I 391055044 J 756582017 K 973262091 L 919574183 M 584331081 N 775915386 O 175156350 P 45635734 Q 928578594 R 496640571 S 678764224 T 268507085 U 110048928 V 167477822 W 909636174 X 8379317...
output:
346372293431
result:
ok single line: '346372293431'
Test #39:
score: -100
Wrong Answer
time: 2ms
memory: 3688kb
input:
14 716061531 A 498316749 B 373305418 C 455531456 D 765787205 E 593658461 F 63911294 G 983798535 H 348572033 I 606225225 J 729414669 K 799648912 L 230507042 M 226990172 N 621879747 339 N 464456354 N 601653126 G 983806768 K 799666165 B 373316428 J 126108232 H 348581656 H 317960564 N 446278844 F 575408...
output:
201244055032
result:
wrong answer 1st lines differ - expected: '206967461904', found: '201244055032'