結果

問題 No.335 門松宝くじ
ユーザー ayaoniayaoni
提出日時 2020-12-18 00:48:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 258 ms / 2,000 ms
コード長 2,020 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 99,164 KB
最終ジャッジ日時 2023-10-21 07:42:33
合計ジャッジ時間 3,372 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,392 KB
testcase_01 AC 41 ms
53,392 KB
testcase_02 AC 41 ms
53,392 KB
testcase_03 AC 40 ms
53,392 KB
testcase_04 AC 40 ms
53,392 KB
testcase_05 AC 166 ms
84,764 KB
testcase_06 AC 189 ms
85,604 KB
testcase_07 AC 210 ms
94,224 KB
testcase_08 AC 160 ms
96,856 KB
testcase_09 AC 254 ms
99,164 KB
testcase_10 AC 249 ms
99,056 KB
testcase_11 AC 256 ms
98,572 KB
testcase_12 AC 250 ms
98,764 KB
testcase_13 AC 258 ms
97,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,T = MI()
expected = []
for _ in range(T):
    E = LI()

    m = [[0]*N for _ in range(N)]
    for i in range(N):
        x = 1000
        for j in range(i,N):
            x = min(x,E[j])
            m[i][j] = x
    M = [[0]*N for _ in range(N)]
    for i in range(N):
        y = -1
        for j in range(i,N):
            y = max(y,E[j])
            M[i][j] = y

    exp = 0
    for i in range(N-1):
        a = E[i]
        for j in range(i+1,N):
            b = E[j]

            if i == 0:
                X_min = 1000
                X_max = 0
            else:
                X_min = m[0][i-1]
                X_max = M[0][i-1]
            if j == i+1:
                Y_min = 1000
                Y_max = 0
            else:
                Y_min = m[i+1][j-1]
                Y_max = M[i+1][j-1]
            if j == N-1:
                Z_min = 1000
                Z_max = 0
            else:
                Z_min = m[j+1][-1]
                Z_max = M[j+1][-1]

            e = 0
            if a < b:
                if X_max > a or Y_min < a or Y_max > b or Z_min < b:
                    e = b
                else:
                    continue
                e = max(e,X_max,Y_max)
            else:
                if X_min < a or Y_min < b or Y_max > a or Z_max > b:
                    e = a
                else:
                    continue
                e = max(e,Y_max,Z_max)
            exp += e

    expected.append(exp)

max_expected = max(expected)
for i in range(T):
    if expected[i] == max_expected:
        print(i)
        break
0