Submission #61563119


Source Code Expand

Copy
import sys
def main():
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
diff = [0] * (N + 2)
B = [0] * N
curSum = 0
for j in range(1, N + 1):
curSum += diff[j]
total = A[j - 1] + curSum
tmp = min(total, N - j)
B[j - 1] = total - tmp
if tmp > 0:
start = j + 1
end = j + tmp + 1
if start <= N:
diff[start] += 1
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import sys


def main():
    N = int(sys.stdin.readline())
    A = list(map(int, sys.stdin.readline().split()))

    diff = [0] * (N + 2)
    B = [0] * N
    curSum = 0

    for j in range(1, N + 1):
        curSum += diff[j]
        total = A[j - 1] + curSum
        tmp = min(total, N - j)
        B[j - 1] = total - tmp
        if tmp > 0:
            start = j + 1
            end = j + tmp + 1
            if start <= N:
                diff[start] += 1
            if end <= N:
                diff[end] -= 1
    print(" ".join(map(str, B)))


if __name__ == "__main__":
    main()

Submission Info

Submission Time
Task D - Coming of Age Celebration
User caomeinaixi
Language Python (PyPy 3.10-v7.3.12)
Score 400
Code Size 616 Byte
Status AC
Exec Time 156 ms
Memory 164572 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 23
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt
Case Name Status Exec Time Memory
sample00.txt AC 56 ms 76708 KB
sample01.txt AC 56 ms 76672 KB
sample02.txt AC 56 ms 76320 KB
testcase00.txt AC 56 ms 76452 KB
testcase01.txt AC 115 ms 164124 KB
testcase02.txt AC 138 ms 164572 KB
testcase03.txt AC 135 ms 136772 KB
testcase04.txt AC 151 ms 159200 KB
testcase05.txt AC 82 ms 105724 KB
testcase06.txt AC 151 ms 159720 KB
testcase07.txt AC 134 ms 133272 KB
testcase08.txt AC 156 ms 159404 KB
testcase09.txt AC 138 ms 136952 KB
testcase10.txt AC 155 ms 159496 KB
testcase11.txt AC 92 ms 116016 KB
testcase12.txt AC 150 ms 159648 KB
testcase13.txt AC 114 ms 135688 KB
testcase14.txt AC 149 ms 159448 KB
testcase15.txt AC 68 ms 90488 KB
testcase16.txt AC 151 ms 159716 KB
testcase17.txt AC 133 ms 136764 KB
testcase18.txt AC 122 ms 163528 KB
testcase19.txt AC 108 ms 156212 KB


2025-03-01 (Sat)
05:39:22 +00:00