QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#216051#5149. Best Carry Playerjason#WA 1ms3440kbC++14959b2023-10-15 15:26:372023-10-15 15:26:38

Judging History

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

  • [2023-10-15 15:26:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3440kb
  • [2023-10-15 15:26:37]
  • 提交

answer

#include<bits/stdc++.h>
#define pii pair<int,int>
#define x first
#define y second
#define int long long
using namespace std;

const int N=2e5+5;
int a[N];
void slove(){
    int n,s,res=0,ans,tmp;cin>>n;
    // cin>>s;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    s = a[n];
    for(int i=n-1,x;i>=1;--i){
        x = a[i];
        // cin>>x;
        tmp = ans=s+x;
        bool f1=1,f2=1;
        while(tmp){
            int a=tmp%10,b=s%10,c=x%10,flag=0;
            if(s==0)f1=0;
            if(x==0)f2=0;
            if(f1&&a<b){
                flag=1;
            }
            if(f2&&a<c){
                flag=1;
            }
            if(flag)    ++res;
            tmp/=10,s/=10,x/=10;
        }
        s = ans;
    }
    cout<<res<<"\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    int t;cin>>t;
    while(t--){
        slove();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3440kb

input:

2
3
9 99 999
1
12345

output:

4
0

result:

wrong answer 1st numbers differ - expected: '5', found: '4'