結果
問題 | No.1898 Battle and Exchange |
ユーザー | Shirotsume |
提出日時 | 2021-12-23 16:49:59 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,696 bytes |
コンパイル時間 | 355 ms |
コンパイル使用メモリ | 82,464 KB |
実行使用メモリ | 225,576 KB |
最終ジャッジ日時 | 2024-09-22 05:47:36 |
合計ジャッジ時間 | 52,195 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
54,652 KB |
testcase_01 | AC | 40 ms
54,680 KB |
testcase_02 | AC | 40 ms
53,912 KB |
testcase_03 | WA | - |
testcase_04 | AC | 96 ms
76,784 KB |
testcase_05 | AC | 99 ms
76,056 KB |
testcase_06 | AC | 114 ms
77,240 KB |
testcase_07 | WA | - |
testcase_08 | AC | 89 ms
76,640 KB |
testcase_09 | AC | 205 ms
78,784 KB |
testcase_10 | AC | 41 ms
53,572 KB |
testcase_11 | AC | 53 ms
63,860 KB |
testcase_12 | AC | 95 ms
76,588 KB |
testcase_13 | AC | 40 ms
53,468 KB |
testcase_14 | AC | 100 ms
76,996 KB |
testcase_15 | AC | 40 ms
53,948 KB |
testcase_16 | AC | 89 ms
76,440 KB |
testcase_17 | AC | 246 ms
79,636 KB |
testcase_18 | AC | 728 ms
89,372 KB |
testcase_19 | AC | 1,095 ms
94,424 KB |
testcase_20 | AC | 1,099 ms
94,472 KB |
testcase_21 | AC | 2,029 ms
115,060 KB |
testcase_22 | AC | 54 ms
65,560 KB |
testcase_23 | AC | 80 ms
74,620 KB |
testcase_24 | AC | 86 ms
76,024 KB |
testcase_25 | AC | 105 ms
76,672 KB |
testcase_26 | AC | 44 ms
60,200 KB |
testcase_27 | AC | 109 ms
77,660 KB |
testcase_28 | AC | 114 ms
77,724 KB |
testcase_29 | AC | 141 ms
78,152 KB |
testcase_30 | AC | 111 ms
76,696 KB |
testcase_31 | AC | 62 ms
67,352 KB |
testcase_32 | AC | 461 ms
92,024 KB |
testcase_33 | AC | 863 ms
104,828 KB |
testcase_34 | AC | 361 ms
88,604 KB |
testcase_35 | AC | 563 ms
96,320 KB |
testcase_36 | WA | - |
testcase_37 | AC | 334 ms
84,992 KB |
testcase_38 | AC | 4,155 ms
225,576 KB |
testcase_39 | AC | 2,514 ms
167,400 KB |
testcase_40 | AC | 2,956 ms
189,816 KB |
testcase_41 | AC | 2,193 ms
159,916 KB |
testcase_42 | AC | 214 ms
79,540 KB |
testcase_43 | AC | 1,830 ms
117,620 KB |
testcase_44 | AC | 58 ms
67,916 KB |
testcase_45 | AC | 281 ms
81,056 KB |
testcase_46 | AC | 767 ms
93,980 KB |
testcase_47 | AC | 223 ms
79,128 KB |
testcase_48 | AC | 330 ms
84,388 KB |
testcase_49 | AC | 139 ms
77,576 KB |
testcase_50 | AC | 125 ms
77,644 KB |
testcase_51 | AC | 134 ms
77,780 KB |
testcase_52 | AC | 129 ms
77,700 KB |
testcase_53 | AC | 268 ms
81,944 KB |
testcase_54 | AC | 234 ms
81,932 KB |
testcase_55 | AC | 390 ms
85,740 KB |
testcase_56 | AC | 346 ms
85,984 KB |
testcase_57 | AC | 3,381 ms
128,004 KB |
testcase_58 | AC | 3,023 ms
126,008 KB |
testcase_59 | AC | 3,547 ms
129,392 KB |
testcase_60 | AC | 2,755 ms
126,392 KB |
ソースコード
import heapq def solve(n, m, graph, abc): for i in range(n): abc[i].sort(reverse = True) def check(x): #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 else: continue myabc.sort(reverse=True) myabc[1] = max(myabc[1], abc[0][1]) myabc[2] = max(myabc[2], abc[0][0]) 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 else: return False ok = 3 * 10 ** 8 ng = 1 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) abc = [list(map(int,input().split())) for _ in range(n)] a, b, c = solve(n, m, graph, abc) print(a, b, c)