結果
問題 | No.1898 Battle and Exchange |
ユーザー | Shirotsume |
提出日時 | 2022-03-09 11:31:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,581 ms / 5,000 ms |
コード長 | 1,762 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 225,452 KB |
最終ジャッジ日時 | 2024-10-05 11:23:39 |
合計ジャッジ時間 | 47,352 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
54,752 KB |
testcase_01 | AC | 37 ms
54,468 KB |
testcase_02 | AC | 36 ms
53,544 KB |
testcase_03 | AC | 37 ms
53,296 KB |
testcase_04 | AC | 89 ms
76,232 KB |
testcase_05 | AC | 90 ms
76,492 KB |
testcase_06 | AC | 105 ms
76,512 KB |
testcase_07 | AC | 106 ms
76,324 KB |
testcase_08 | AC | 84 ms
76,620 KB |
testcase_09 | AC | 194 ms
78,852 KB |
testcase_10 | AC | 39 ms
53,568 KB |
testcase_11 | AC | 51 ms
64,876 KB |
testcase_12 | AC | 87 ms
76,644 KB |
testcase_13 | AC | 36 ms
53,272 KB |
testcase_14 | AC | 94 ms
76,876 KB |
testcase_15 | AC | 40 ms
53,808 KB |
testcase_16 | AC | 84 ms
76,068 KB |
testcase_17 | AC | 226 ms
79,144 KB |
testcase_18 | AC | 680 ms
89,660 KB |
testcase_19 | AC | 981 ms
94,332 KB |
testcase_20 | AC | 972 ms
94,960 KB |
testcase_21 | AC | 2,050 ms
114,876 KB |
testcase_22 | AC | 50 ms
64,572 KB |
testcase_23 | AC | 72 ms
74,580 KB |
testcase_24 | AC | 72 ms
75,052 KB |
testcase_25 | AC | 94 ms
77,072 KB |
testcase_26 | AC | 40 ms
59,596 KB |
testcase_27 | AC | 99 ms
77,380 KB |
testcase_28 | AC | 101 ms
77,272 KB |
testcase_29 | AC | 124 ms
77,952 KB |
testcase_30 | AC | 99 ms
77,184 KB |
testcase_31 | AC | 55 ms
68,216 KB |
testcase_32 | AC | 369 ms
92,156 KB |
testcase_33 | AC | 742 ms
104,820 KB |
testcase_34 | AC | 290 ms
88,200 KB |
testcase_35 | AC | 459 ms
96,180 KB |
testcase_36 | AC | 435 ms
94,420 KB |
testcase_37 | AC | 288 ms
85,004 KB |
testcase_38 | AC | 3,581 ms
225,452 KB |
testcase_39 | AC | 2,155 ms
167,484 KB |
testcase_40 | AC | 2,603 ms
190,392 KB |
testcase_41 | AC | 1,869 ms
159,660 KB |
testcase_42 | AC | 197 ms
79,672 KB |
testcase_43 | AC | 1,661 ms
118,136 KB |
testcase_44 | AC | 55 ms
66,584 KB |
testcase_45 | AC | 267 ms
80,988 KB |
testcase_46 | AC | 730 ms
94,020 KB |
testcase_47 | AC | 198 ms
79,120 KB |
testcase_48 | AC | 308 ms
83,740 KB |
testcase_49 | AC | 134 ms
77,440 KB |
testcase_50 | AC | 117 ms
77,376 KB |
testcase_51 | AC | 122 ms
77,248 KB |
testcase_52 | AC | 117 ms
77,368 KB |
testcase_53 | AC | 249 ms
81,948 KB |
testcase_54 | AC | 217 ms
81,916 KB |
testcase_55 | AC | 368 ms
85,228 KB |
testcase_56 | AC | 346 ms
85,496 KB |
testcase_57 | AC | 3,130 ms
128,464 KB |
testcase_58 | AC | 2,760 ms
126,132 KB |
testcase_59 | AC | 3,118 ms
129,644 KB |
testcase_60 | AC | 2,573 ms
126,352 KB |
ソースコード
import heapq def solve(n, m, graph, abc): for i in range(n): abc[i].sort(reverse = True) 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 else: pass 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: continue if now != 0: myabc.sort(reverse=True) myabc[1] = max(myabc[1], abc[now][1]) myabc[2] = max(myabc[2], abc[now][0]) else: pass 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)