QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#735460#6300. Best Carry Player 2dsbdsb#WA 0ms3664kbC++14745b2024-11-11 20:11:132024-11-11 20:11:13

Judging History

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

  • [2024-11-11 20:11:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2024-11-11 20:11:13]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=(k);++i)
#define MAXN 25
typedef long long ll;
ll task,n,m,cnt,a[MAXN];
ll base[MAXN],f[MAXN][MAXN][2];
inline void solve(){
	std::cin>>n>>m;
	base[0]=1;
	rep(i,1,18) base[i]=base[i-1]*10;
	while(n%10==0) ++cnt,n/=10;
	rep(i,1,18) a[i]=n%10,n/=10;
	rep(i,0,18) rep(j,0,18) rep(k,0,1) f[i][j][k]=1e18;
	f[0][0][0]=0;
	rep(i,0,17) rep(j,0,i) rep(k,0,1){
		ll cur=a[i+1]+k;
		ll &x=f[i+1][j+(cur>=10)][cur>=10];
		ll &y=f[i+1][j+1][1];
		x=std::min(x,f[i][j][k]);
		y=std::min(y,f[i][j][k]+base[i]*(10-cur));
	}
	std::cout<<std::min(f[18][m][0],f[18][m][1]);
	rep(i,1,cnt) std::cout<<0;
	std::cout<<'\n';
}
int main(){
	std::cin>>task;
	while(task--) solve();
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3664kb

input:

4
12345678 0
12345678 5
12345678 18
990099 5

output:

0
54322
999999999987654322
9910

result:

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