結果
問題 |
No.335 門松宝くじ
|
ユーザー |
|
提出日時 | 2016-01-16 00:34:39 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,538 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-09-19 19:45:07 |
合計ジャッジ時間 | 5,135 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 WA * 1 |
ソースコード
def calc_score(E, N): maxLeft, minLeft = calc_max_min_left(E) maxRight, minRight = calc_max_min_right(E) score = 0 for L in range(N-1): EL = E[L] for R in range(L + 1, N): if EL < E[R]: s = 0 if L: maxL = maxLeft[L - 1] if maxL > EL: s = max(E[R], maxL) if R < N - 1: minR = minRight[R + 1] if minR < E[R]: s = max(s, E[R]) else: s = 0 if L: minL = minLeft[L - 1] if minL < EL: s = EL if R < N - 1: maxR = maxRight[R + 1] if maxR > E[R]: s = max(s, EL, maxR) score += s return score def calc_max_min_left(E): maxL = 0 minL = 1000 maxLeft = [] minLeft = [] for e in E: maxL = max(maxL, e) minL = min(minL, e) maxLeft.append(maxL) minLeft.append(minL) return maxLeft, minLeft def calc_max_min_right(E): revE = E[:] revE.reverse() maxRight, minRight = calc_max_min_left(revE) maxRight.reverse() minRight.reverse() return maxRight, minRight N, M = map(int, input().split()) Es = [] for m in range(M): Es.append(list(map(int, input().split()))) scores = [calc_score(E, N) for E in Es] maxS = max(scores) print(scores.index(maxS))