QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#277447 | #5149. Best Carry Player | zzuqy# | WA | 14ms | 3624kb | C++14 | 952b | 2023-12-06 19:02:48 | 2023-12-06 19:02:48 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define db double
#define endl '\n'
#define rep(x,y,z) for(int x=y;x<=z;++x)
#define fep(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int N=1e5+10;
int T,n,a[N],b[N],c[N][20],m[N];
inline void run()
{
cin>>n;
rep(i,1,n) cin>>a[i];
rep(i,1,n)
{
int x=a[i];m[i]=0;
while(x)
{
c[i][++m[i]]=x%10;
x/=10;
}
}
int M=m[1],ans=0;
rep(i,1,20) b[i]=c[1][i];
rep(i,2,n)
{
int now=0;
rep(j,1,m[i])
{
b[j]+=c[i][j]+now;
if(b[j]>10)
{
ans++;
now=b[j]/10;
b[j]%=10;
}
}
rep(j,m[i]+1,M)
{
b[j]+=now;
if(b[j]>10)
{
ans++;
now=b[j]/10;
b[j]%=10;
}
}
if(now)
{
b[++M]=now;
ans++;
}
}
cout<<ans<<endl;
}
int main()
{
// freopen("1.in","r",stdin);
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>T;
while(T--) run();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3624kb
input:
2 3 9 99 999 1 12345
output:
5 0
result:
ok 2 number(s): "5 0"
Test #2:
score: 0
Accepted
time: 14ms
memory: 3592kb
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: 10ms
memory: 3584kb
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:
51 51 50 46 52 43 54 48 47 56 44 51 54 48 49 50 50 49 47 50 50 51 49 52 52 50 49 54 45 51 46 49 51 49 47 48 59 47 52 45 53 53 55 49 48 50 49 50 52 48 46 55 49 55 46 51 51 47 47 54 51 49 52 51 53 54 52 52 50 52 49 50 50 53 50 51 50 52 52 47 50 52 44 52 51 49 55 48 47 50 48 47 47 51 51 53 54 52 42 49 ...
result:
wrong answer 1st numbers differ - expected: '42', found: '51'