Submission #59584375


Source Code Expand

# 入力
N, M = map(int, input().split())
X = list(map(int, input().split()))  # 石の位置
A = list(map(int, input().split()))  # それぞれの位置の石の数

if sum(A)!=N:
    print(-1)
    exit()

stone=[0]*N
ans=0

for i in range(M):
    stone[X[i]-1]=A[i]


for i in range(N-1):
    if stone[i]>=2:
        ans+=stone[i]-1
        stone[i+1]+=stone[i]-1
        stone[i]=1
    elif stone[i]==0:
        print(-1)
        exit()

print(ans)

Submission Info

Submission Time
Task C - Sowing Stones
User serithq
Language Python (PyPy 3.10-v7.3.12)
Score 0
Code Size 477 Byte
Status RE
Exec Time 167 ms
Memory 137872 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 30
RE × 13
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 02_hand_00.txt, 02_hand_01.txt, 02_hand_02.txt, 02_hand_03.txt, 02_hand_04.txt, 02_hand_05.txt, 02_hand_06.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 58 ms 76608 KiB
00_sample_01.txt AC 58 ms 76456 KiB
01_random_00.txt AC 87 ms 120784 KiB
01_random_01.txt AC 93 ms 123716 KiB
01_random_02.txt AC 108 ms 132968 KiB
01_random_03.txt AC 93 ms 124212 KiB
01_random_04.txt AC 83 ms 116300 KiB
01_random_05.txt AC 95 ms 130156 KiB
01_random_06.txt AC 102 ms 137872 KiB
01_random_07.txt AC 95 ms 128912 KiB
01_random_08.txt AC 99 ms 122936 KiB
01_random_09.txt RE 164 ms 121668 KiB
01_random_10.txt RE 138 ms 105404 KiB
01_random_11.txt RE 145 ms 117392 KiB
01_random_12.txt AC 78 ms 102476 KiB
01_random_13.txt AC 79 ms 105284 KiB
01_random_14.txt AC 81 ms 105988 KiB
01_random_15.txt AC 83 ms 112996 KiB
01_random_16.txt AC 110 ms 116508 KiB
01_random_17.txt AC 96 ms 117296 KiB
01_random_18.txt AC 72 ms 93084 KiB
01_random_19.txt AC 86 ms 114636 KiB
01_random_20.txt RE 167 ms 126208 KiB
01_random_21.txt AC 107 ms 126136 KiB
01_random_22.txt RE 166 ms 126428 KiB
01_random_23.txt AC 105 ms 126108 KiB
01_random_24.txt RE 163 ms 126408 KiB
01_random_25.txt AC 104 ms 126236 KiB
01_random_26.txt RE 165 ms 126248 KiB
01_random_27.txt AC 105 ms 126132 KiB
01_random_28.txt RE 118 ms 82544 KiB
01_random_29.txt AC 59 ms 76400 KiB
01_random_30.txt RE 120 ms 82560 KiB
01_random_31.txt AC 59 ms 76216 KiB
01_random_32.txt RE 117 ms 82724 KiB
01_random_33.txt AC 59 ms 76256 KiB
02_hand_00.txt AC 104 ms 115752 KiB
02_hand_01.txt AC 92 ms 117316 KiB
02_hand_02.txt AC 81 ms 108584 KiB
02_hand_03.txt AC 75 ms 99260 KiB
02_hand_04.txt RE 119 ms 82716 KiB
02_hand_05.txt RE 118 ms 82396 KiB
02_hand_06.txt RE 165 ms 126228 KiB