結果
問題 | No.1898 Battle and Exchange |
ユーザー | Shirotsume |
提出日時 | 2022-03-20 01:19:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,254 ms / 5,000 ms |
コード長 | 1,710 bytes |
コンパイル時間 | 146 ms |
コンパイル使用メモリ | 81,972 KB |
実行使用メモリ | 223,400 KB |
最終ジャッジ日時 | 2024-10-05 14:54:20 |
合計ジャッジ時間 | 35,696 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
53,880 KB |
testcase_01 | AC | 36 ms
53,380 KB |
testcase_02 | AC | 35 ms
54,144 KB |
testcase_03 | AC | 37 ms
53,184 KB |
testcase_04 | AC | 64 ms
72,252 KB |
testcase_05 | AC | 66 ms
70,136 KB |
testcase_06 | AC | 94 ms
76,592 KB |
testcase_07 | AC | 93 ms
76,596 KB |
testcase_08 | AC | 66 ms
74,700 KB |
testcase_09 | AC | 157 ms
78,668 KB |
testcase_10 | AC | 35 ms
53,520 KB |
testcase_11 | AC | 48 ms
64,120 KB |
testcase_12 | AC | 63 ms
74,792 KB |
testcase_13 | AC | 34 ms
54,440 KB |
testcase_14 | AC | 67 ms
74,460 KB |
testcase_15 | AC | 35 ms
53,624 KB |
testcase_16 | AC | 77 ms
76,408 KB |
testcase_17 | AC | 160 ms
78,888 KB |
testcase_18 | AC | 306 ms
88,896 KB |
testcase_19 | AC | 530 ms
94,556 KB |
testcase_20 | AC | 316 ms
94,740 KB |
testcase_21 | AC | 1,029 ms
114,148 KB |
testcase_22 | AC | 53 ms
66,040 KB |
testcase_23 | AC | 57 ms
68,504 KB |
testcase_24 | AC | 61 ms
70,784 KB |
testcase_25 | AC | 98 ms
76,504 KB |
testcase_26 | AC | 40 ms
54,276 KB |
testcase_27 | AC | 94 ms
77,256 KB |
testcase_28 | AC | 95 ms
77,128 KB |
testcase_29 | AC | 111 ms
77,952 KB |
testcase_30 | AC | 94 ms
77,052 KB |
testcase_31 | AC | 47 ms
62,648 KB |
testcase_32 | AC | 365 ms
91,956 KB |
testcase_33 | AC | 646 ms
104,828 KB |
testcase_34 | AC | 276 ms
88,164 KB |
testcase_35 | AC | 428 ms
95,380 KB |
testcase_36 | AC | 349 ms
95,576 KB |
testcase_37 | AC | 243 ms
85,064 KB |
testcase_38 | AC | 3,254 ms
223,400 KB |
testcase_39 | AC | 940 ms
160,084 KB |
testcase_40 | AC | 2,238 ms
188,408 KB |
testcase_41 | AC | 848 ms
152,748 KB |
testcase_42 | AC | 179 ms
79,408 KB |
testcase_43 | AC | 535 ms
114,928 KB |
testcase_44 | AC | 55 ms
66,492 KB |
testcase_45 | AC | 223 ms
81,244 KB |
testcase_46 | AC | 559 ms
93,604 KB |
testcase_47 | AC | 183 ms
79,604 KB |
testcase_48 | AC | 167 ms
82,184 KB |
testcase_49 | AC | 121 ms
77,604 KB |
testcase_50 | AC | 129 ms
77,680 KB |
testcase_51 | AC | 108 ms
77,344 KB |
testcase_52 | AC | 107 ms
77,532 KB |
testcase_53 | AC | 192 ms
81,552 KB |
testcase_54 | AC | 213 ms
81,608 KB |
testcase_55 | AC | 316 ms
85,688 KB |
testcase_56 | AC | 234 ms
84,788 KB |
testcase_57 | AC | 2,550 ms
127,156 KB |
testcase_58 | AC | 1,714 ms
125,608 KB |
testcase_59 | AC | 1,590 ms
128,496 KB |
testcase_60 | AC | 1,585 ms
126,408 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 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]) 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 ok = 3 * 10 ** 8 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) abc = [list(map(int,input().split())) for _ in range(n)] a, b, c = solve(n, m, graph, abc) print(a, b, c)