結果
問題 | No.1898 Battle and Exchange |
ユーザー | Shirotsume |
提出日時 | 2022-03-20 01:24:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,338 ms / 5,000 ms |
コード長 | 1,736 bytes |
コンパイル時間 | 191 ms |
コンパイル使用メモリ | 81,976 KB |
実行使用メモリ | 203,492 KB |
最終ジャッジ日時 | 2024-10-05 15:07:01 |
合計ジャッジ時間 | 38,857 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
52,864 KB |
testcase_01 | AC | 37 ms
52,864 KB |
testcase_02 | AC | 37 ms
52,864 KB |
testcase_03 | AC | 37 ms
52,864 KB |
testcase_04 | AC | 60 ms
67,456 KB |
testcase_05 | AC | 62 ms
68,736 KB |
testcase_06 | AC | 104 ms
76,636 KB |
testcase_07 | AC | 92 ms
76,248 KB |
testcase_08 | AC | 71 ms
72,960 KB |
testcase_09 | AC | 168 ms
78,820 KB |
testcase_10 | AC | 39 ms
54,528 KB |
testcase_11 | AC | 52 ms
64,052 KB |
testcase_12 | AC | 82 ms
76,712 KB |
testcase_13 | AC | 36 ms
53,756 KB |
testcase_14 | AC | 82 ms
76,744 KB |
testcase_15 | AC | 39 ms
53,016 KB |
testcase_16 | AC | 84 ms
75,852 KB |
testcase_17 | AC | 182 ms
79,076 KB |
testcase_18 | AC | 377 ms
88,176 KB |
testcase_19 | AC | 560 ms
92,640 KB |
testcase_20 | AC | 403 ms
94,492 KB |
testcase_21 | AC | 1,083 ms
114,964 KB |
testcase_22 | AC | 49 ms
61,408 KB |
testcase_23 | AC | 63 ms
68,920 KB |
testcase_24 | AC | 65 ms
70,424 KB |
testcase_25 | AC | 94 ms
76,696 KB |
testcase_26 | AC | 41 ms
58,516 KB |
testcase_27 | AC | 93 ms
76,680 KB |
testcase_28 | AC | 110 ms
77,492 KB |
testcase_29 | AC | 125 ms
78,160 KB |
testcase_30 | AC | 99 ms
76,572 KB |
testcase_31 | AC | 51 ms
64,064 KB |
testcase_32 | AC | 439 ms
93,728 KB |
testcase_33 | AC | 909 ms
106,868 KB |
testcase_34 | AC | 409 ms
90,932 KB |
testcase_35 | AC | 511 ms
94,944 KB |
testcase_36 | AC | 420 ms
92,488 KB |
testcase_37 | AC | 274 ms
84,568 KB |
testcase_38 | AC | 3,338 ms
203,492 KB |
testcase_39 | AC | 1,094 ms
152,624 KB |
testcase_40 | AC | 2,715 ms
180,516 KB |
testcase_41 | AC | 956 ms
149,936 KB |
testcase_42 | AC | 187 ms
79,000 KB |
testcase_43 | AC | 583 ms
112,576 KB |
testcase_44 | AC | 64 ms
70,764 KB |
testcase_45 | AC | 264 ms
81,772 KB |
testcase_46 | AC | 659 ms
93,432 KB |
testcase_47 | AC | 204 ms
79,416 KB |
testcase_48 | AC | 222 ms
83,124 KB |
testcase_49 | AC | 129 ms
77,484 KB |
testcase_50 | AC | 121 ms
77,728 KB |
testcase_51 | AC | 116 ms
77,636 KB |
testcase_52 | AC | 114 ms
77,748 KB |
testcase_53 | AC | 244 ms
82,412 KB |
testcase_54 | AC | 230 ms
81,840 KB |
testcase_55 | AC | 367 ms
85,032 KB |
testcase_56 | AC | 266 ms
84,936 KB |
testcase_57 | AC | 2,610 ms
122,396 KB |
testcase_58 | AC | 1,714 ms
122,308 KB |
testcase_59 | AC | 1,562 ms
127,948 KB |
testcase_60 | AC | 2,520 ms
131,428 KB |
ソースコード
import heapq def solve(n, m, graph, abc): global ok def check(x): first = True #A = x, B = 1, C = 1で突破できる? myabc = [x, 1, 1] q = [] good = [False] * n visit = [False] * n if sum(abc[0]) >= sum(myabc): return False myabc[1] = abc[0][0] good[0] = True visit[0] = True for to in graph[0]: visit[to] = True heapq.heappush(q, (sum(abc[to]), to)) while q: nowsum, now = heapq.heappop(q) if nowsum < sum(myabc): good[now] = True if first: first = False myabc[2] = abc[0][1] else: return False if now != 0: myabc.sort(reverse=True) myabc[1] = max(myabc[1], abc[now][1]) myabc[2] = max(myabc[2], abc[now][0]) for to in graph[now]: if not visit[to]: visit[to] = True heapq.heappush(q, (sum(abc[to]), to)) if good[n - 1]: return True return False ng = 3 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if check(mid): ok = mid else: ng = mid return ok, 1, 1 n, m = map(int,input().split()) graph = [[] for _ in range(n)] for _ in range(m): u, v = map(int,input().split()) u -= 1 v -= 1 graph[u].append(v) graph[v].append(u) ok = 0 abc = [list(map(int,input().split())) for _ in range(n)] for i in range(n): abc[i].sort(reverse = True) ok = max(ok , sum(abc[i])) a, b, c = solve(n, m, graph, abc) print(a, b, c)