結果
問題 | No.999 てん vs. ほむ |
ユーザー | FromBooska |
提出日時 | 2023-02-27 20:35:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,127 bytes |
コンパイル時間 | 267 ms |
コンパイル使用メモリ | 87,216 KB |
実行使用メモリ | 127,388 KB |
最終ジャッジ日時 | 2023-10-13 05:10:53 |
合計ジャッジ時間 | 4,599 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,220 KB |
testcase_01 | AC | 68 ms
71,512 KB |
testcase_02 | AC | 68 ms
71,300 KB |
testcase_03 | AC | 72 ms
71,556 KB |
testcase_04 | AC | 74 ms
71,304 KB |
testcase_05 | WA | - |
testcase_06 | AC | 72 ms
71,308 KB |
testcase_07 | AC | 71 ms
71,376 KB |
testcase_08 | AC | 85 ms
76,732 KB |
testcase_09 | AC | 147 ms
121,248 KB |
testcase_10 | AC | 96 ms
87,928 KB |
testcase_11 | AC | 89 ms
82,144 KB |
testcase_12 | AC | 105 ms
93,744 KB |
testcase_13 | AC | 152 ms
127,388 KB |
testcase_14 | AC | 154 ms
127,268 KB |
testcase_15 | AC | 154 ms
127,104 KB |
testcase_16 | AC | 152 ms
127,208 KB |
testcase_17 | AC | 134 ms
109,536 KB |
testcase_18 | WA | - |
testcase_19 | AC | 132 ms
109,652 KB |
testcase_20 | WA | - |
testcase_21 | AC | 148 ms
126,952 KB |
testcase_22 | AC | 147 ms
126,392 KB |
ソースコード
# 公式解説より # なんと区間dpではない、区間dpで解けるが間に合わない # 全部のゲームを見渡すと、左からkセットでは、先手が左側、後手が右側を取る # 右から(N-k)セットでは、先手が右側、後手が左側を取る # 累積和で高速化して、最大値を探せばいい N = int(input()) A = list(map(int, input().split())) from_left = [] for i in range(N): calc = A[i*2]-A[i*2+1] from_left.append(calc) from_left_cum = [0] temp = 0 for i in range(N): temp += from_left[i] from_left_cum.append(temp) from_right = [] for i in range(N): calc = A[(N-1-i)*2+1]-A[(N-1-i)*2] from_right.append(calc) from_right_cum = [] temp = 0 for i in range(N): temp += from_right[i] from_right_cum.append(temp) from_right = from_right[::-1] from_right_cum = from_right_cum[::-1] from_right_cum.append(0) #print(from_left) #print(from_left_cum) #print(from_right) #print(from_right_cum) ans = -10**20 for i in range(N): #Nより少ないけどまあいいか ans = max(ans, from_left_cum[i]+from_right_cum[i]) print(ans)