QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#277451#5149. Best Carry Playerzzuqy#WA 0ms3664kbC++14954b2023-12-06 19:06:122023-12-06 19:06:12

Judging History

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

  • [2023-12-06 19:06:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2023-12-06 19:06:12]
  • 提交

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: 0
Wrong Answer
time: 0ms
memory: 3664kb

input:

2
3
9 99 999
1
12345

output:

7
0

result:

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