結果

問題 No.335 門松宝くじ
ユーザー roarisroaris
提出日時 2019-12-11 13:45:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 828 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 86,652 KB
実行使用メモリ 71,500 KB
最終ジャッジ日時 2023-09-06 13:03:34
合計ジャッジ時間 4,687 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,260 KB
testcase_01 AC 64 ms
71,336 KB
testcase_02 AC 67 ms
71,360 KB
testcase_03 AC 68 ms
71,420 KB
testcase_04 AC 66 ms
71,500 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
v_max = -1
ans = None

for m in range(M):
    E = list(map(lambda x: x-1, map(int, input().split())))
    idx = [-1]*N
    
    for i in range(N):
        idx[E[i]] = i
    
    v = 0
    
    for i in range(N):
        for j in range(i+1, N):
            prof = 0
            
            for k in range(N):
                if k in [i, j]:
                    continue
                
                l = [(i, idx[i]), (j, idx[j]), (k, idx[k])]
                l.sort(key=lambda k: k[1])
                l2 = [li[0] for li in l]
                
                if (l2[0]<l2[1] and l2[1]>l2[2]) or (l2[0]>l2[1] and l2[1]<l2[2]):
                    prof = max(prof, max(i, j, k))
            
            v += prof
            
    if v_max<v:
        v_max = v
        ans = m
    
print(ans)
0