結果
問題 | No.1898 Battle and Exchange |
ユーザー | Shirotsume |
提出日時 | 2021-12-23 16:49:14 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,693 bytes |
コンパイル時間 | 341 ms |
コンパイル使用メモリ | 81,640 KB |
実行使用メモリ | 106,596 KB |
最終ジャッジ日時 | 2023-10-22 04:38:08 |
合計ジャッジ時間 | 20,063 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge9 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
59,036 KB |
testcase_01 | AC | 46 ms
53,364 KB |
testcase_02 | AC | 48 ms
58,808 KB |
testcase_03 | WA | - |
testcase_04 | AC | 122 ms
76,072 KB |
testcase_05 | AC | 121 ms
76,080 KB |
testcase_06 | AC | 134 ms
76,336 KB |
testcase_07 | WA | - |
testcase_08 | AC | 106 ms
75,992 KB |
testcase_09 | AC | 301 ms
78,756 KB |
testcase_10 | AC | 48 ms
58,808 KB |
testcase_11 | AC | 70 ms
70,336 KB |
testcase_12 | AC | 125 ms
77,032 KB |
testcase_13 | AC | 42 ms
53,364 KB |
testcase_14 | AC | 131 ms
76,952 KB |
testcase_15 | AC | 49 ms
60,996 KB |
testcase_16 | AC | 111 ms
75,932 KB |
testcase_17 | AC | 427 ms
80,712 KB |
testcase_18 | AC | 1,718 ms
96,456 KB |
testcase_19 | AC | 2,442 ms
104,992 KB |
testcase_20 | AC | 2,526 ms
106,596 KB |
testcase_21 | TLE | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
testcase_55 | -- | - |
testcase_56 | -- | - |
testcase_57 | -- | - |
testcase_58 | -- | - |
testcase_59 | -- | - |
testcase_60 | -- | - |
ソースコード
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 = 10 ** 15 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)