QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#412342#5149. Best Carry Playerhuangbrother#WA 72ms3624kbC++17729b2024-05-16 12:04:192024-05-16 12:04:19

Judging History

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

  • [2024-05-16 12:04:19]
  • 评测
  • 测评结果:WA
  • 用时:72ms
  • 内存:3624kb
  • [2024-05-16 12:04:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int a[100010];
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,ans=0;
        cin>>n;
        priority_queue<int,vector<int>,greater<int>>q;
        for(int i=1;i<=n;i++)cin>>a[i],q.push(a[i]);

        while(q.size()>1){
            int m1=q.top();
            q.pop();
            int m2=q.top();
            q.pop();
            int k=m1+m2;
            int carry=0,res=0;
            while(m1||m2){
                int res=m1%10+m2%10+carry;
                if(res>=10)carry=1,ans++;
                else carry=0;
                m1/=10,m2/=10;
            }
            q.push(k);
        }
        cout<<ans<<endl;
        
    }
}

详细

Test #1:

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

input:

2
3
9 99 999
1
12345

output:

5
0

result:

ok 2 number(s): "5 0"

Test #2:

score: 0
Accepted
time: 72ms
memory: 3624kb

input:

100000
1
481199252
1
634074578
1
740396295
1
579721198
1
503722503
1
202647942
1
268792718
1
443917727
1
125908043
1
717268783
1
150414369
1
519096230
1
856168102
1
674936674
1
274667941
1
527268921
1
421436316
1
286802932
1
646837311
1
451394766
1
105650419
1
302790137
1
254786900
1
76141081
1
7393...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #3:

score: -100
Wrong Answer
time: 37ms
memory: 3612kb

input:

10000
10
598196518 640274071 983359971 71550121 96204862 799843967 446173607 796619138 402690754 223219513
10
312183499 905549873 673542337 566661387 879397647 434495917 631413076 150918417 579868000 224422012
10
525305826 535526356 404334728 653535984 998133227 879226371 59632864 356493387 62611196...

output:

39
33
36
29
32
25
38
29
31
35
27
40
39
35
33
35
39
39
28
33
30
36
32
35
35
32
31
43
30
35
35
36
37
31
36
30
40
33
37
29
37
38
36
34
35
42
32
32
36
31
31
38
34
34
38
37
36
31
32
36
33
29
34
39
35
44
34
37
36
31
28
33
32
38
37
35
34
37
41
33
33
37
25
32
37
35
37
27
32
39
36
26
29
33
28
33
33
33
27
31
...

result:

wrong answer 1st numbers differ - expected: '42', found: '39'