UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197868#2773. 搞个大新闻snow_trace100645ms7612kbC++993b2023-11-16 09:48:522023-11-16 12:04:01

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[1000005];
/*
I’m all by myself seen this show like a thousand times
It’s a side effect loneliness without no reply
In my mind I just keep pretending it’s a big old lie
Big old lie big old lie
Dancing on the tables city full of angels
Dreams of diamonds and gold
All the different faces ones I used to hate
I miss them now that they’re gone
Oh my God did we go too far
Did we waste it all like we’re running out of roses
Plastic cups did we laugh enough
Looking back on us now that everything is over
*/
priority_queue<int,vector<int>,greater<int> >q;
signed main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >>n;
    for(int i = 1;i<=n;i++)cin>>a[i];
    int ans = 0;
    for(int i = 1;i<=n;i++){
        if(!q.empty() and q.top()<=a[i]){
            ans+=a[i]-q.top();q.pop();q.push(a[i]);
        }q.push(a[i]);
    }cout<< ans<<endl;
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 55
Accepted

Test #1:

score: 55
Accepted
time: 0ms
memory: 1260kb

input:

15
367950 863101 867551 211502 786411 639194 190846 250492 294220 962198 851577 28239 263134 519649 ...

output:

3183010

result:

ok single line: '3183010'

Test #2:

score: 0
Accepted
time: 0ms
memory: 1264kb

input:

15
295794 691784 527233 817761 183044 775841 413456 908253 57400 201140 936313 179414 473046 998723 ...

output:

4053721

result:

ok single line: '4053721'

Test #3:

score: 0
Accepted
time: 0ms
memory: 1264kb

input:

15
886997 486007 145985 967542 358106 916556 568534 112776 835733 39768 652831 355377 535854 362290 ...

output:

3510033

result:

ok single line: '3510033'

Test #4:

score: 0
Accepted
time: 0ms
memory: 1264kb

input:

15
516164 895229 978820 35520 358884 229074 288014 193428 456843 551919 802212 939605 146759 625609 ...

output:

2946049

result:

ok single line: '2946049'

Test #5:

score: 0
Accepted
time: 0ms
memory: 1264kb

input:

15
926049 682423 416907 210848 222222 700242 277074 856658 517539 322081 223794 550883 710492 239424...

output:

2281250

result:

ok single line: '2281250'

Test #6:

score: 0
Accepted
time: 0ms
memory: 1260kb

input:

9
10 5 4 7 9 12 6 2 10

output:

20

result:

ok single line: '20'

Test #7:

score: 0
Accepted
time: 0ms
memory: 1260kb

input:

2
4 77

output:

73

result:

ok single line: '73'

Subtask #2:

score: 10
Accepted

Test #8:

score: 10
Accepted
time: 0ms
memory: 1264kb

input:

100
834390 727645 163213 188116 69362 441393 893827 50625 185623 962851 216156 69419 379492 872901 2...

output:

22132507

result:

ok single line: '22132507'

Test #9:

score: 0
Accepted
time: 0ms
memory: 1264kb

input:

100
807826 316913 41173 54425 112990 341886 823962 668111 897684 969429 887804 987413 755687 298168 ...

output:

26676513

result:

ok single line: '26676513'

Test #10:

score: 0
Accepted
time: 0ms
memory: 1260kb

input:

100
922308 609010 180154 49136 712811 115974 697859 65429 15059 984225 191001 939442 310529 603195 2...

output:

24069769

result:

ok single line: '24069769'

Test #11:

score: 0
Accepted
time: 0ms
memory: 1264kb

input:

100
707562 251288 885686 835546 575982 141619 824654 446793 600572 258217 524565 509293 895852 22134...

output:

21002218

result:

ok single line: '21002218'

Test #12:

score: 0
Accepted
time: 0ms
memory: 1260kb

input:

100
627961 256111 868661 473325 748974 102088 56698 155382 759465 971488 286405 351556 43544 919064 ...

output:

24525989

result:

ok single line: '24525989'

Subtask #3:

score: 20
Accepted

Test #13:

score: 20
Accepted
time: 0ms
memory: 1412kb

input:

5000
919797 313483 912306 564183 817668 907158 29794 648738 425376 481857 312862 984189 472703 57259...

output:

1247272629

result:

ok single line: '1247272629'

Test #14:

score: 0
Accepted
time: 0ms
memory: 1408kb

input:

5000
983893 221272 411939 152035 212623 648825 826979 170061 988625 344015 557037 24321 152538 74080...

output:

1246155002

result:

ok single line: '1246155002'

Test #15:

score: 0
Accepted
time: 1ms
memory: 1408kb

input:

5000
87404 158522 351460 580071 299688 531770 6354 889537 126583 191317 782234 501808 733088 459262 ...

output:

1255015308

result:

ok single line: '1255015308'

Test #16:

score: 0
Accepted
time: 0ms
memory: 1412kb

input:

5000
329192 760260 820659 262470 552540 738638 394830 154052 305727 504105 716130 736368 731039 5061...

output:

1259348540

result:

ok single line: '1259348540'

Test #17:

score: 0
Accepted
time: 0ms
memory: 1412kb

input:

5000
957749 393611 971661 201382 85944 979755 452787 713179 957653 401568 554946 263270 25954 760941...

output:

1244313764

result:

ok single line: '1244313764'

Subtask #4:

score: 10
Accepted

Test #18:

score: 10
Accepted
time: 49ms
memory: 7608kb

input:

300000
1 11 11 13 15 23 23 24 27 31 33 37 39 70 78 79 84 90 100 109 115 117 118 124 125 126 127 130 ...

output:

74803302089

result:

ok single line: '74803302089'

Test #19:

score: 0
Accepted
time: 35ms
memory: 7608kb

input:

300000
1 12 16 16 17 19 20 21 25 29 30 30 34 35 40 40 41 46 48 56 57 57 57 60 61 65 79 81 95 99 120 ...

output:

74881676552

result:

ok single line: '74881676552'

Test #20:

score: 0
Accepted
time: 43ms
memory: 7608kb

input:

300000
3 12 12 14 15 20 23 24 26 27 31 37 41 43 48 50 53 55 55 56 56 61 66 67 69 69 72 78 79 79 80 8...

output:

74901386430

result:

ok single line: '74901386430'

Test #21:

score: 0
Accepted
time: 46ms
memory: 7608kb

input:

300000
3 10 14 17 19 19 22 23 27 32 34 41 41 43 47 48 55 58 63 66 67 72 72 74 80 83 83 87 90 91 93 9...

output:

74755035235

result:

ok single line: '74755035235'

Test #22:

score: 0
Accepted
time: 42ms
memory: 7608kb

input:

300000
8 13 15 16 20 24 25 25 32 37 38 44 46 46 50 51 51 59 67 68 73 75 75 76 77 77 80 82 82 84 85 8...

output:

74894790298

result:

ok single line: '74894790298'

Subtask #5:

score: 5
Accepted

Test #23:

score: 5
Accepted
time: 45ms
memory: 7612kb

input:

300000
461376 118673 291702 583976 691386 30677 791864 434251 355340 469979 148978 658122 308414 236...

output:

74720948906

result:

ok single line: '74720948906'

Test #24:

score: 0
Accepted
time: 49ms
memory: 7612kb

input:

300000
60983 908156 627680 604922 760039 435685 127605 883724 731042 164380 768165 418486 205391 713...

output:

74812975195

result:

ok single line: '74812975195'

Test #25:

score: 0
Accepted
time: 53ms
memory: 7612kb

input:

300000
190594 636764 929393 400629 580368 166227 90434 127775 428188 505187 127761 240795 522797 978...

output:

74846280504

result:

ok single line: '74846280504'

Test #26:

score: 0
Accepted
time: 49ms
memory: 7608kb

input:

300000
499105 305779 171883 44380 659445 225696 514592 816389 641722 942448 958069 711610 283031 644...

output:

74677233515

result:

ok single line: '74677233515'

Test #27:

score: 0
Accepted
time: 56ms
memory: 7608kb

input:

300000
883093 210560 852621 922668 996566 343498 648909 783740 740220 859395 127185 829012 161486 98...

output:

74819673637

result:

ok single line: '74819673637'

Test #28:

score: 0
Accepted
time: 46ms
memory: 7612kb

input:

300000
76 60 30 94 93 74 85 35 99 48 92 84 43 57 41 50 58 82 5 75 52 52 38 74 61 37 8 45 71 67 52 90...

output:

7488172

result:

ok single line: '7488172'

Test #29:

score: 0
Accepted
time: 46ms
memory: 7608kb

input:

300000
46 87 53 12 38 97 10 62 67 78 96 21 4 22 42 41 60 44 78 79 78 50 94 10 78 90 70 40 97 50 75 9...

output:

7492787

result:

ok single line: '7492787'

Test #30:

score: 0
Accepted
time: 44ms
memory: 7608kb

input:

300000
11 54 27 24 87 1 36 81 95 29 7 20 5 43 90 25 14 79 75 60 19 41 85 63 73 93 47 72 46 23 26 92 ...

output:

7497485

result:

ok single line: '7497485'

Test #31:

score: 0
Accepted
time: 41ms
memory: 7612kb

input:

300000
8 5 10 7 2 1 1 7 5 5 4 9 4 9 3 10 5 1 8 1 6 7 7 8 10 10 1 6 1 6 10 9 1 3 8 8 2 5 1 6 6 1 5 8 ...

output:

748486

result:

ok single line: '748486'