QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#419633#6564. Frequent FlierohiostatescarletRE 15ms10612kbPython3828b2024-05-24 05:18:522024-05-24 05:18:52

Judging History

This is the latest submission verdict.

  • [2024-05-24 05:18:52]
  • Judged
  • Verdict: RE
  • Time: 15ms
  • Memory: 10612kb
  • [2024-05-24 05:18:52]
  • Submitted

answer



n, m, k = map(int, input().split())

a = [int(input()) for _ in range(n)]

count = 0
counts = [0 for _ in range(n)]
nextZero = [i - 1 for i in range(n)]


for start in range(-m + 1, n):
    index = min(start + m - 1, n - 1)
    # print("index", index, count)
    prev = -1

    while k - count > 0 and index >= 0 and index >= start:
        # print(a[index], counts[index], k, count)
        add = min(a[index] - counts[index], k - count)
        counts[index] += add
        count += add

        if counts[index] == a[index]:
            if prev >= 0:
                nextZero[prev] = index + 1
            prev = index
            index = nextZero[index]
    # print("-"*20)
    # print(counts)
    # print(nextZero)

    if start >= 0:
        count -= counts[start]


print(sum(counts))

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 15ms
memory: 10612kb

input:

8 3 2
3
1
4
1
5
9
2
6

output:

8

result:

ok single line: '8'

Test #2:

score: -100
Dangerous Syscalls

input:

200000 2467 999931035
182548858
69876218
33328350
919486767
739850600
948199964
392292320
39077742
366752074
917496841
246661698
37219034
56677740
188278971
965701828
28059790
13200243
825730775
542597589
320715170
939054378
470563899
914247467
990100491
290827128
903662394
611104879
18631185
412134...

output:


result: