QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#355852 | #5460. Sum of Numbers | ucup-team1001# | RE | 0ms | 0kb | Python3 | 972b | 2024-03-17 11:26:46 | 2024-03-17 11:26:47 |
answer
a = 0
b = 0
qwq = ""
ans = 0
vis = 0
now = []
n = 0
k = 0
def check():
now2 = []
global a, b, n, k, ans, vis, now
a = (n // (k + 1))
b = ((n + k) // (k + 1))
cur = 0
if sum(now) != n - (n // (k + 1) * (k + 1)):
return
for x in now:
if x == 0:
now2.append(int(qwq[cur: cur + a]))
cur += a
else:
now2.append(int(qwq[cur: cur + b]))
cur += b
if vis == 0:
ans = sum(now2)
else:
ans = max(ans, sum(now2))
def dfs(cur):
global a, b, n, k, ans, vis, now
x = n // (k + 1)
if cur == k + 1:
check()
return
else:
now.append(0)
dfs(cur + 1)
now.pop(cur)
now.append(1)
dfs(cur + 1)
now.pop(cur)
t = int(input())
while t:
ans = 0
n, k = [int(x) for x in input().split()]
qwq = input()
dfs(0)
print(ans)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
2 8 1 45455151 2 1 42
output:
9696 6