QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#129469#6300. Best Carry Player 2sinsop90WA 1ms3656kbC++14928b2023-07-22 19:52:582023-07-22 19:57:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-22 19:57:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3656kb
  • [2023-07-22 19:52:58]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
int T, n, k, f[25][25][2], vis[25][25][2];
void solve() {
	scanf("%lld%lld", &n, &k);
	memset(vis, 0, sizeof(vis)), memset(f, 0x3f3f3f, sizeof(f));
	int now = 1;
	vis[0][0][0] = 1, f[0][0][0] = 0;
	for(int i = 1;i <= 18;i++) {
		int g = n / now % 10;
		for(int j = 0;j <= k;j++) {
			if(vis[i - 1][j][0]) {
				f[i][j + 1][1] = min(f[i][j + 1][1], f[i - 1][j][0] + now * (10 - g));
				f[i][j][0] = min(f[i][j][0], f[i - 1][j][0]);	
				vis[i][j + 1][1] = vis[i][j][0] = 1;
			}
			if(vis[i - 1][j][1]) {
				f[i][j + 1][1] = min(f[i][j + 1][1], f[i - 1][j][1] + now * (10 - 1 - g));
				if(g != 9) f[i][j][0] = min(f[i][j][0], f[i - 1][j][1]), vis[i][j][0] = 1;
				vis[i][j + 1][1] = 1;
			}
			
		}
		now *= 10;
	}
	printf("%lld\n", min(f[18][k][1], f[18][k][0]));
}
signed main() {
	scanf("%lld", &T);
	while(T --) solve();
}

詳細信息

Test #1:

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

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'