QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#32799#2281. BnPCRobeZH#WA 146ms22912kbC++1.3kb2022-05-24 03:48:072022-05-24 03:48:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-24 03:48:07]
  • 评测
  • 测评结果:WA
  • 用时:146ms
  • 内存:22912kb
  • [2022-05-24 03:48:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=1;i<=n;++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define st first
#define nd second
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
int n,k,l;
map<string,int>a;
map<string,vi>e;
ll ans,infmx;
vector<ll>ftp;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    rep(i,n){
        string s;int x;
        cin>>s>>x;
        a[s]=x;
    }
    cin>>l;
    rep(i,l){
        string s;int x;
        cin>>s>>x;
        e[s].pb(x);
    }
    ans=infmx=0;
    for(auto p:a){
        vi&v=e[p.st];
        if(v.size()==0)continue;
        sort(all(v));
        int mx=v.back();
        if(mx>=p.nd){
            k-=mx-p.nd;
            ll cnt=0;
            for(int x:v)if(x<mx)ans+=mx;else ++cnt;
            infmx=max(infmx,(ll)v.size());
            ftp.pb(cnt*mx+v.size());
        }else{
            for(int x:v)ans+=p.nd;
            infmx=max(infmx,(ll)v.size());
        }
    }
    sort(all(ftp));
    if(k<0)cout<<0<<endl;
    else{
        while(k>0&&ftp.size()>0&&ftp.back()>infmx){
            ans+=ftp.back();
            --k;
            ftp.pop_back();
        }
        ans+=k*infmx;
        cout<<ans<<endl;
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3700kb

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: 2ms
memory: 3708kb

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: 3ms
memory: 3632kb

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: 0ms
memory: 3588kb

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: 0ms
memory: 3576kb

input:

1 1
OVERENTHUSIASTICNESS 41
1
OVERENTHUSIASTICNESS 0

output:

42

result:

ok single line: '42'

Test #6:

score: 0
Accepted
time: 146ms
memory: 22912kb

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: 138ms
memory: 22728kb

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: 11ms
memory: 3904kb

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: 3552kb

input:

1 1
A 0
1
A 0

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 3ms
memory: 3632kb

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: 15ms
memory: 3904kb

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: 57ms
memory: 13328kb

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: 1ms
memory: 4256kb

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: 3ms
memory: 3696kb

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: 13ms
memory: 4700kb

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: 1ms
memory: 3604kb

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: -100
Wrong Answer
time: 15ms
memory: 4156kb

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:

54558472276054

result:

wrong answer 1st lines differ - expected: '0', found: '54558472276054'