Submission #24246739


Source Code Expand

import numpy as np

A = np.array(open(0).read().split(), np.int64)[1:]

diff_A = np.diff(A)
diff_B = np.maximum(0, diff_A)
diff_C = np.maximum(0, -diff_A)

# C[0] = 0 としたときの B, C
B = np.cumsum(np.append(A[0], diff_B))
C = np.cumsum(np.append(0, diff_C))

p = np.concatenate((B, C))
median = np.partition(p, len(A))[len(A)]
ans = np.abs(p - median).sum()

print(ans)

Submission Info

Submission Time
Task D - Inc, Dec - Decomposition
User maspy
Language Python (3.8.2)
Score 700
Code Size 393 Byte
Status AC
Exec Time 176 ms
Memory 51952 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 40
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 02_small_10.txt, 03_rand_01.txt, 03_rand_02.txt, 03_rand_03.txt, 03_rand_04.txt, 03_rand_05.txt, 03_rand_06.txt, 03_rand_07.txt, 03_rand_08.txt, 03_rand_09.txt, 03_rand_10.txt, 03_rand_11.txt, 03_rand_12.txt, 03_rand_13.txt, 03_rand_14.txt, 03_rand_15.txt, 03_rand_16.txt, 03_rand_17.txt, 03_rand_18.txt, 03_rand_19.txt, 03_rand_20.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt, 04_handmade_05.txt, 04_handmade_06.txt, 04_handmade_07.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 115 ms 26876 KiB
01_sample_02.txt AC 109 ms 27104 KiB
01_sample_03.txt AC 108 ms 26912 KiB
02_small_01.txt AC 109 ms 27152 KiB
02_small_02.txt AC 107 ms 26920 KiB
02_small_03.txt AC 112 ms 26660 KiB
02_small_04.txt AC 107 ms 26936 KiB
02_small_05.txt AC 108 ms 26848 KiB
02_small_06.txt AC 107 ms 26932 KiB
02_small_07.txt AC 107 ms 26912 KiB
02_small_08.txt AC 112 ms 26984 KiB
02_small_09.txt AC 111 ms 26776 KiB
02_small_10.txt AC 109 ms 26896 KiB
03_rand_01.txt AC 115 ms 28276 KiB
03_rand_02.txt AC 141 ms 37892 KiB
03_rand_03.txt AC 139 ms 37700 KiB
03_rand_04.txt AC 111 ms 27564 KiB
03_rand_05.txt AC 151 ms 42100 KiB
03_rand_06.txt AC 115 ms 28368 KiB
03_rand_07.txt AC 139 ms 37368 KiB
03_rand_08.txt AC 158 ms 43760 KiB
03_rand_09.txt AC 164 ms 46856 KiB
03_rand_10.txt AC 168 ms 47736 KiB
03_rand_11.txt AC 118 ms 30092 KiB
03_rand_12.txt AC 132 ms 34224 KiB
03_rand_13.txt AC 141 ms 37968 KiB
03_rand_14.txt AC 120 ms 31464 KiB
03_rand_15.txt AC 142 ms 37712 KiB
03_rand_16.txt AC 154 ms 43780 KiB
03_rand_17.txt AC 119 ms 31104 KiB
03_rand_18.txt AC 170 ms 48808 KiB
03_rand_19.txt AC 110 ms 27440 KiB
03_rand_20.txt AC 173 ms 49704 KiB
04_handmade_01.txt AC 176 ms 51916 KiB
04_handmade_02.txt AC 175 ms 51772 KiB
04_handmade_03.txt AC 148 ms 48304 KiB
04_handmade_04.txt AC 173 ms 51804 KiB
04_handmade_05.txt AC 173 ms 51804 KiB
04_handmade_06.txt AC 172 ms 51952 KiB
04_handmade_07.txt AC 174 ms 51636 KiB