結果
問題 | No.999 てん vs. ほむ |
ユーザー | O2MT |
提出日時 | 2020-12-15 00:47:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 314 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 81,688 KB |
実行使用メモリ | 109,080 KB |
最終ジャッジ日時 | 2023-10-20 05:30:02 |
合計ジャッジ時間 | 3,506 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
53,412 KB |
testcase_01 | AC | 42 ms
53,412 KB |
testcase_02 | AC | 41 ms
53,412 KB |
testcase_03 | AC | 42 ms
53,412 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 42 ms
55,460 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 100 ms
109,068 KB |
testcase_18 | AC | 99 ms
108,228 KB |
testcase_19 | AC | 101 ms
109,068 KB |
testcase_20 | AC | 99 ms
109,080 KB |
testcase_21 | AC | 115 ms
105,172 KB |
testcase_22 | AC | 115 ms
104,920 KB |
ソースコード
from collections import deque N = int(input()) A = list(map(int,input().split())) if N == 1: print(max(A)-min(A)) exit() B = [] for i in range(0,2*N-1,2): B.append(A[i]-A[i+1]) B = deque(B) ans = 0 while B: if B[0] > -B[-1]: ans += B.popleft() else: ans += -B.pop() print(ans)