QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#216075#5137. Towerkrito2023#WA 1ms3492kbC++201003b2023-10-15 15:33:562023-10-15 15:33:56

Judging History

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

  • [2023-10-15 15:33:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3492kb
  • [2023-10-15 15:33:56]
  • 提交

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(a==9&&b==9&&c==9)    ++res;
            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: 3492kb

input:

3
2 0
2 6
5 0
1 2 3 4 5
5 3
1 2 3 4 5

output:

0
1
1

result:

wrong answer 1st numbers differ - expected: '2', found: '0'