結果
問題 | No.335 門松宝くじ |
ユーザー | HIROPON87069639 |
提出日時 | 2016-02-11 17:46:55 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 536 ms / 2,000 ms |
コード長 | 2,535 bytes |
コンパイル時間 | 47 ms |
コンパイル使用メモリ | 7,040 KB |
実行使用メモリ | 6,400 KB |
最終ジャッジ日時 | 2024-09-22 00:53:32 |
合計ジャッジ時間 | 4,585 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
6,272 KB |
testcase_01 | AC | 11 ms
6,144 KB |
testcase_02 | AC | 11 ms
6,144 KB |
testcase_03 | AC | 12 ms
6,272 KB |
testcase_04 | AC | 12 ms
6,272 KB |
testcase_05 | AC | 148 ms
6,400 KB |
testcase_06 | AC | 218 ms
6,144 KB |
testcase_07 | AC | 363 ms
6,400 KB |
testcase_08 | AC | 409 ms
6,400 KB |
testcase_09 | AC | 529 ms
6,272 KB |
testcase_10 | AC | 536 ms
6,400 KB |
testcase_11 | AC | 532 ms
6,400 KB |
testcase_12 | AC | 529 ms
6,400 KB |
testcase_13 | AC | 528 ms
6,400 KB |
ソースコード
# 2016.2.11 def maxgetter(inpstr): out = [] inp = inpstr[0:len(inpstr)] inp.reverse() tmp = 0 for i in range(0, len(inp)): if inp[i] > tmp: tmp = inp[i] out.append(tmp) out.reverse() return out def mingetter(inpstr): out = [] inp = inpstr[0:len(inpstr)] inp.reverse() tmp = 100000 for i in range(0, len(inp)): if inp[i] < tmp: tmp = inp[i] out.append(tmp) out.reverse() return out def omikuji(inp): global N total = 0 kuji = map(int, inp.split()) maxlist = maxgetter(kuji) minlist = mingetter(kuji) sec1max = kuji[0] sec1min = kuji[0] for i in range(0, N-1): if sec1max < kuji[i-1] and i != 0: sec1max = kuji[i-1] if sec1min > kuji[i-1] and i != 0: sec1min = kuji[i-1] A = kuji[i] sec2max = kuji[i+1] sec2min = kuji[i+1] for j in range(i+1, N): if sec2max < kuji[j-1] and j != i+1: sec2max = kuji[j-1] if sec2min > kuji[j-1] and j != i+1: sec2min = kuji[j-1] B = kuji[j] flag = 0 if A < B: if sec1max > A: flag = 1 if sec2min < A: flag = 1 if max(sec1max, sec2max) > B: flag = 2 if flag == 0 and j != N-1: if B > minlist[j+1]: flag = 1 flag2point = max(sec1max, sec2max) elif A > B: if sec1min < A: flag = 1 if sec2min < B: flag = 1 if sec2max > A: flag = 2 sec3max = 0 if j != N-1: sec3max = maxlist[j+1] if B < sec3max < A and flag != 2: flag = 1 if sec3max > A: flag = 2 flag2point = max(sec2max, sec3max) if flag == 1: total += max(A, B) elif flag == 2: total += flag2point return total NM = map(int, raw_input().split()) N = NM[0] M = NM[1] totalpoint = [0 for no in range(0, M)] for no in range(0, M): totalpoint[no] = omikuji((raw_input())) totalpointmax = 0 ans = 0 for i in range(0, M): if totalpointmax < totalpoint[i]: totalpointmax = totalpoint[i] ans = i print ans