結果
問題 | No.1150 シュークリームゲーム(Easy) |
ユーザー |
|
提出日時 | 2020-08-07 22:57:13 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 740 bytes |
コンパイル時間 | 1,145 ms |
コンパイル使用メモリ | 82,084 KB |
実行使用メモリ | 849,220 KB |
最終ジャッジ日時 | 2024-09-24 23:23:46 |
合計ジャッジ時間 | 6,937 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
55,616 KB |
testcase_01 | AC | 47 ms
56,272 KB |
testcase_02 | AC | 45 ms
55,532 KB |
testcase_03 | AC | 45 ms
55,920 KB |
testcase_04 | AC | 45 ms
55,716 KB |
testcase_05 | AC | 46 ms
55,696 KB |
testcase_06 | AC | 44 ms
55,044 KB |
testcase_07 | AC | 45 ms
56,136 KB |
testcase_08 | AC | 44 ms
55,296 KB |
testcase_09 | AC | 47 ms
57,520 KB |
testcase_10 | AC | 46 ms
56,564 KB |
testcase_11 | AC | 44 ms
55,180 KB |
testcase_12 | AC | 47 ms
56,888 KB |
testcase_13 | AC | 46 ms
55,672 KB |
testcase_14 | AC | 51 ms
61,092 KB |
testcase_15 | AC | 49 ms
62,648 KB |
testcase_16 | AC | 50 ms
61,208 KB |
testcase_17 | AC | 133 ms
79,912 KB |
testcase_18 | AC | 253 ms
98,016 KB |
testcase_19 | AC | 278 ms
104,696 KB |
testcase_20 | AC | 221 ms
96,732 KB |
testcase_21 | AC | 253 ms
96,396 KB |
testcase_22 | MLE | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
ソースコード
#!/usr/bin/env pypy3 N=int(input()) s, t = input().split() s = int(s) t = int(t) s -= 1 t -= 1 A = list(map(int, input().split())) assert(len(A) == N) q1 = [] i = (s+1) % N while i != t: q1 += [A[i]] i += 1 i %= N q2 = [] i = (s-1) % N while i != t: q2 += [A[i]] i -= 1 i %= N from functools import lru_cache @lru_cache(None) def ans(q1, q2): if len(q1) == 0 and len(q2) == 0: return 0 if len(q1) == 0: qh, *qt = q2 return qh - ans(q1[::-1], tuple(qt)[::-1]) if len(q2) == 0: qh, *qt = q1 return qh - ans(tuple(qt)[::-1], q2[::-1]) q1h, *q1t = q1 q2h, *q2t = q2 return max( q2h - ans(q1[::-1], tuple(q2t)[::-1]), q1h - ans(tuple(q1t)[::-1], q2[::-1]) ) print(A[s] - A[t] + ans(tuple(q1), tuple(q2)))