結果
問題 | No.1898 Battle and Exchange |
ユーザー | Shirotsume |
提出日時 | 2021-12-06 19:14:48 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,586 bytes |
コンパイル時間 | 435 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 233,424 KB |
最終ジャッジ日時 | 2024-09-22 05:49:41 |
合計ジャッジ時間 | 52,932 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
54,300 KB |
testcase_01 | AC | 39 ms
53,776 KB |
testcase_02 | AC | 39 ms
53,536 KB |
testcase_03 | AC | 39 ms
53,696 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 52 ms
63,136 KB |
testcase_12 | AC | 102 ms
76,912 KB |
testcase_13 | AC | 40 ms
53,512 KB |
testcase_14 | AC | 99 ms
76,892 KB |
testcase_15 | AC | 42 ms
54,576 KB |
testcase_16 | AC | 89 ms
76,312 KB |
testcase_17 | AC | 225 ms
79,176 KB |
testcase_18 | AC | 539 ms
89,176 KB |
testcase_19 | AC | 884 ms
94,164 KB |
testcase_20 | AC | 1,080 ms
97,536 KB |
testcase_21 | AC | 2,554 ms
120,952 KB |
testcase_22 | AC | 52 ms
62,936 KB |
testcase_23 | AC | 85 ms
76,132 KB |
testcase_24 | AC | 81 ms
74,376 KB |
testcase_25 | AC | 103 ms
76,896 KB |
testcase_26 | AC | 44 ms
59,272 KB |
testcase_27 | AC | 106 ms
77,588 KB |
testcase_28 | AC | 109 ms
77,256 KB |
testcase_29 | AC | 126 ms
77,932 KB |
testcase_30 | AC | 96 ms
76,712 KB |
testcase_31 | AC | 58 ms
66,412 KB |
testcase_32 | AC | 368 ms
95,652 KB |
testcase_33 | WA | - |
testcase_34 | AC | 292 ms
89,744 KB |
testcase_35 | AC | 493 ms
101,208 KB |
testcase_36 | WA | - |
testcase_37 | AC | 346 ms
85,476 KB |
testcase_38 | AC | 3,528 ms
216,484 KB |
testcase_39 | AC | 2,201 ms
167,876 KB |
testcase_40 | AC | 3,807 ms
233,424 KB |
testcase_41 | AC | 2,563 ms
177,648 KB |
testcase_42 | AC | 190 ms
78,780 KB |
testcase_43 | AC | 1,937 ms
122,236 KB |
testcase_44 | AC | 68 ms
70,944 KB |
testcase_45 | AC | 238 ms
80,728 KB |
testcase_46 | AC | 768 ms
95,632 KB |
testcase_47 | AC | 215 ms
79,144 KB |
testcase_48 | AC | 342 ms
84,220 KB |
testcase_49 | AC | 135 ms
77,636 KB |
testcase_50 | AC | 133 ms
77,568 KB |
testcase_51 | AC | 138 ms
77,724 KB |
testcase_52 | AC | 128 ms
77,768 KB |
testcase_53 | AC | 328 ms
82,692 KB |
testcase_54 | AC | 241 ms
82,108 KB |
testcase_55 | AC | 348 ms
85,804 KB |
testcase_56 | AC | 368 ms
85,716 KB |
testcase_57 | WA | - |
testcase_58 | AC | 3,685 ms
135,240 KB |
testcase_59 | AC | 3,666 ms
134,352 KB |
testcase_60 | AC | 3,091 ms
129,556 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で突破できる? a = x b = 1 c = 1 q = [] good = [False] * n visit = [False] * n if sum(abc[0]) >= a + b + c: return False b = abc[0][0] good[0] = True visit[0] = True for to in graph[0]: visit[to] = True heapq.heappush(q, (sum(abc[to]), to)) if not q: return False else: c = max(c, abc[0][1]) while q: nowsum, now = heapq.heappop(q) if nowsum < a + b + c: good[now] = True if b > c: b, c = c, b b = max(b, abc[now][0]) c = max(c, abc[now][1]) 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 ** 9 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)] print(*solve(n, m, graph, abc))