Submission #33852104


Source Code Expand

import numpy as np
def main(N, L, R, A):
    filledL = np.cumsum([0] + [L] * N)
    
    A = A[::-1]
    acc = np.cumsum([0] + A)
    filledR = np.cumsum([0] + [R] * N)
    
    # 各項の値が大きいほど、置き換え後の総和は小さくなる
    # processed[0]は0で一つも置き換えない(y = 0)ことを意味する
    processed = acc - filledR
    
    # 全てLで置き換える(x = N, y = 0)
    ans = filledL[N]
    
    # 0 <= x < N
    better_y = 0
    for x in range(N-1, -1, -1):
        i = N - x
        if processed[i] > processed[better_y]:
            better_y = i
        
        ans = min(ans, filledL[x] + filledR[better_y] + acc[i] - acc[better_y])
        
    return ans

N, L, R = map(int, input().split())
*A, = map(int, input().split())

print(main(N, L, R, A))

Submission Info

Submission Time
Task D - Left Right Operation
User arakaki_tokyo
Language Python (3.8.2)
Score 400
Code Size 836 Byte
Status AC
Exec Time 411 ms
Memory 51404 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 38
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.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, 02_max_01.txt, 02_max_02.txt, 02_max_03.txt, 02_max_04.txt, 02_max_05.txt, 02_max_06.txt, 02_max_07.txt, 02_max_08.txt, 02_max_09.txt, 02_max_10.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt, 03_handmade_05.txt, 03_handmade_06.txt, 03_handmade_07.txt, 03_handmade_08.txt, 03_handmade_09.txt, 03_handmade_10.txt, 04_hack_01.txt, 04_hack_02.txt, 04_hack_03.txt, 04_hack_04.txt, 04_hack_05.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 112 ms 26664 KiB
00_sample_02.txt AC 107 ms 26900 KiB
00_sample_03.txt AC 108 ms 26660 KiB
01_random_01.txt AC 116 ms 27788 KiB
01_random_02.txt AC 219 ms 34532 KiB
01_random_03.txt AC 391 ms 47480 KiB
01_random_04.txt AC 230 ms 35848 KiB
01_random_05.txt AC 110 ms 27176 KiB
01_random_06.txt AC 144 ms 29396 KiB
01_random_07.txt AC 244 ms 36460 KiB
01_random_08.txt AC 173 ms 31252 KiB
01_random_09.txt AC 201 ms 33752 KiB
01_random_10.txt AC 395 ms 48840 KiB
02_max_01.txt AC 404 ms 49648 KiB
02_max_02.txt AC 409 ms 49524 KiB
02_max_03.txt AC 401 ms 49924 KiB
02_max_04.txt AC 405 ms 49668 KiB
02_max_05.txt AC 406 ms 49248 KiB
02_max_06.txt AC 406 ms 49436 KiB
02_max_07.txt AC 411 ms 49272 KiB
02_max_08.txt AC 409 ms 49200 KiB
02_max_09.txt AC 406 ms 49444 KiB
02_max_10.txt AC 405 ms 49388 KiB
03_handmade_01.txt AC 397 ms 51376 KiB
03_handmade_02.txt AC 402 ms 51360 KiB
03_handmade_03.txt AC 401 ms 50680 KiB
03_handmade_04.txt AC 400 ms 50508 KiB
03_handmade_05.txt AC 399 ms 51216 KiB
03_handmade_06.txt AC 397 ms 51328 KiB
03_handmade_07.txt AC 398 ms 51240 KiB
03_handmade_08.txt AC 395 ms 51404 KiB
03_handmade_09.txt AC 402 ms 50948 KiB
03_handmade_10.txt AC 400 ms 51340 KiB
04_hack_01.txt AC 378 ms 38056 KiB
04_hack_02.txt AC 398 ms 50168 KiB
04_hack_03.txt AC 402 ms 49916 KiB
04_hack_04.txt AC 396 ms 50092 KiB
04_hack_05.txt AC 398 ms 49964 KiB