結果

問題 No.2182 KODOKU Stone
ユーザー MasKoaTSMasKoaTS
提出日時 2022-09-15 16:05:42
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 954 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 105,320 KB
最終ジャッジ日時 2024-04-26 21:04:52
合計ジャッジ時間 6,834 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,224 KB
testcase_01 AC 35 ms
52,224 KB
testcase_02 AC 36 ms
52,352 KB
testcase_03 RE -
testcase_04 AC 38 ms
52,352 KB
testcase_05 AC 39 ms
52,224 KB
testcase_06 AC 40 ms
52,608 KB
testcase_07 AC 39 ms
52,736 KB
testcase_08 AC 40 ms
52,608 KB
testcase_09 WA -
testcase_10 RE -
testcase_11 AC 226 ms
102,976 KB
testcase_12 WA -
testcase_13 AC 117 ms
98,304 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 255 ms
105,320 KB
testcase_17 AC 82 ms
95,232 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 95 ms
82,432 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 82 ms
76,288 KB
testcase_26 AC 82 ms
75,904 KB
testcase_27 AC 78 ms
76,032 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 179 ms
93,652 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 37 ms
52,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# WA(?)

import sys
input = sys.stdin.readline

N = int(input())
K = list(map(int, input().split()))
T = [0] * N
A = [[] for _ in [0] * N]
st = set([])
ma1, ma2 = 0, 0
for i in range(N):
	T[i] = int(input())
	A[i] = list(map(int, input().split()))
	st |= set(A[i])
	lis = sorted(A[i], reverse = True)
	id1 = min(K[-1], len(lis)) - 1
	id2 = max(id1 - 1, 0)
	ma1 = max(ma1, lis[id1])
	ma2 = max(ma2, lis[id2])

if(ma1 == ma2):
	lis = sorted(st, reverse = True)
	ma1 = lis[1]

def check(md):
	slis = []
	wild = []
	for lis in A:
		s = sum((k >= md) for k in lis)
		if(s == len(lis)):
			wild.append(s)
		else:
			slis.append(s)
	wild.sort(reverse = True)
	slis.sort()
	for i, k in enumerate(K[::-1]):
		s = slis[-1] if(slis) else -1
		w = wild[0] if(wild) else -1
		if(max(s, w) >= k):
			break
		elif(s == k - 1 and i < N - 1):
			slis.pop()
		elif(wild):
			wild.pop()
		else:
			return False
	return True

ans = ma1
if check(ma2):
	ans = ma2

print(ans)
0