QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#88401 | #5460. Sum of Numbers | Yangmf | WA | 185ms | 50624kb | Python3 | 1.4kb | 2023-03-16 09:57:46 | 2023-03-16 09:57:47 |
Judging History
answer
# [n,k]=map(int(),input().split(' '))
# print(n,k)
global cnt
global n,k
cnt = 0
N = 200010
dp = [[-1 for j in range(6+3)] for i in range(N)]
sum = [0 for i in range(N)]
dd = [0 for i in range(N)]
lens = [[-1 for j in range(8)] for i in range(800)]
tmp = [-1 for i in range(8)]
def get(l,r,num):
res = 0
for i in range(l,r+1):
res*=10
res+=int(num[i])
return res
def dfs(len,bk,d,mx):
global n, k
global cnt
if d>=mx:
if(len!=n):
return
cnt = cnt + 1
for i in range(mx):
lens[cnt][i] = tmp[i]
else :
for i in range(-1,2):
tmp[d] = bk+i
dfs(len+bk+i,bk,d+1,mx)
def main():
global n,k,cnt
cnt=0
n,k = map(int,input().split())
num = input()
ans = int(num)
num='.'+num
bk = n//(k+1)
dfs(0,bk,0,k+1)
dd[n]=1
dd[n+1]=1
for i in range(n,0,-1):
sum[i]=sum[i+1]+int(num[i])*dd[i]
for i in range(1,cnt+1):
res = 0
len = 0
for j in range(0,k+1):
xx = lens[i][j]
if(xx==0):
continue
res = res+(sum[len+1]-sum[len+xx+1])//(10**(len))
len += xx
ans=min(ans,res)
print(ans)
for i in range(0,n+3):
sum[i]=dd[i]=0
if __name__ == "__main__":
t = int(input())
for i in range(0,t):
main()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 185ms
memory: 50624kb
input:
2 8 1 45455151 2 1 42
output:
0 0
result:
wrong answer 1st lines differ - expected: '9696', found: '0'