結果
問題 | No.1898 Battle and Exchange |
ユーザー | tamato |
提出日時 | 2022-04-08 23:33:55 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,214 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 82,204 KB |
実行使用メモリ | 187,316 KB |
最終ジャッジ日時 | 2024-11-28 14:47:07 |
合計ジャッジ時間 | 37,698 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
54,156 KB |
testcase_01 | AC | 39 ms
53,384 KB |
testcase_02 | AC | 40 ms
54,024 KB |
testcase_03 | WA | - |
testcase_04 | AC | 55 ms
65,428 KB |
testcase_05 | AC | 58 ms
64,472 KB |
testcase_06 | AC | 98 ms
76,572 KB |
testcase_07 | WA | - |
testcase_08 | AC | 77 ms
73,916 KB |
testcase_09 | AC | 131 ms
78,504 KB |
testcase_10 | AC | 41 ms
53,928 KB |
testcase_11 | AC | 57 ms
66,692 KB |
testcase_12 | AC | 56 ms
66,500 KB |
testcase_13 | AC | 41 ms
53,940 KB |
testcase_14 | AC | 61 ms
68,552 KB |
testcase_15 | AC | 40 ms
54,412 KB |
testcase_16 | AC | 72 ms
73,096 KB |
testcase_17 | AC | 164 ms
78,096 KB |
testcase_18 | AC | 347 ms
84,756 KB |
testcase_19 | AC | 633 ms
88,884 KB |
testcase_20 | AC | 362 ms
89,020 KB |
testcase_21 | AC | 1,034 ms
104,480 KB |
testcase_22 | AC | 54 ms
64,960 KB |
testcase_23 | AC | 55 ms
64,880 KB |
testcase_24 | AC | 65 ms
70,296 KB |
testcase_25 | AC | 89 ms
76,480 KB |
testcase_26 | AC | 41 ms
53,516 KB |
testcase_27 | AC | 93 ms
76,416 KB |
testcase_28 | AC | 93 ms
76,520 KB |
testcase_29 | AC | 106 ms
77,892 KB |
testcase_30 | AC | 86 ms
76,296 KB |
testcase_31 | AC | 49 ms
62,816 KB |
testcase_32 | AC | 334 ms
87,684 KB |
testcase_33 | AC | 609 ms
96,472 KB |
testcase_34 | AC | 266 ms
85,292 KB |
testcase_35 | AC | 405 ms
90,628 KB |
testcase_36 | WA | - |
testcase_37 | AC | 252 ms
83,188 KB |
testcase_38 | AC | 3,745 ms
187,316 KB |
testcase_39 | AC | 708 ms
143,224 KB |
testcase_40 | AC | 2,576 ms
156,892 KB |
testcase_41 | AC | 585 ms
136,064 KB |
testcase_42 | AC | 167 ms
77,884 KB |
testcase_43 | AC | 543 ms
103,924 KB |
testcase_44 | AC | 54 ms
64,604 KB |
testcase_45 | AC | 242 ms
79,540 KB |
testcase_46 | AC | 620 ms
88,356 KB |
testcase_47 | AC | 177 ms
78,272 KB |
testcase_48 | AC | 164 ms
80,672 KB |
testcase_49 | AC | 113 ms
77,480 KB |
testcase_50 | AC | 106 ms
76,628 KB |
testcase_51 | AC | 114 ms
77,364 KB |
testcase_52 | AC | 98 ms
77,068 KB |
testcase_53 | AC | 169 ms
80,144 KB |
testcase_54 | AC | 217 ms
81,080 KB |
testcase_55 | AC | 340 ms
83,228 KB |
testcase_56 | AC | 206 ms
82,568 KB |
testcase_57 | AC | 2,864 ms
112,852 KB |
testcase_58 | AC | 1,862 ms
111,732 KB |
testcase_59 | AC | 1,759 ms
113,536 KB |
testcase_60 | AC | 1,757 ms
110,524 KB |
ソースコード
mod = 998244353 def main(): import sys from heapq import heappop, heappush input = sys.stdin.readline def trade(X, Y): Z = sorted(X + Y, reverse=True) return Z[:3] N, M = map(int, input().split()) adj = [[] for _ in range(N + 1)] for _ in range(M): a, b = map(int, input().split()) adj[a].append(b) adj[b].append(a) ABC = [[0, 0, 0]] * (N + 1) for v in range(1, N+1): ABC[v] = list(map(int, input().split())) ABC_sum = [sum(abc) for abc in ABC] ans = 3 * 10 ** 8 ans_k = -1 for k in range(1): ok = 3 * 10 ** 8 ng = 1 mid = (ok + ng) // 2 while ok - ng > 1: X = [1] * 3 X[k] = mid X_ori = X[:] # 頂点1で勝てるかどうか if sum(X) <= sum(ABC[1]): ng = mid mid = (ok + ng) // 2 continue else: ma_1 = max(ABC[1]) X[1] = max(X[1], ma_1) S = sum(X) flg = 0 for u in adj[1]: if S > ABC_sum[u]: flg = 1 break if not flg: ng = mid mid = (ok + ng) // 2 continue X = trade(X_ori, ABC[1]) seen = [0] * (N + 1) pq = [(0, 1)] seen[1] = 1 flg = 1 while pq: s, v = heappop(pq) if s >= sum(X): flg = 0 break else: if v == N: break X = trade(X, ABC[v]) for u in adj[v]: if not seen[u]: heappush(pq, (ABC_sum[u], u)) seen[u] = 1 if flg: ok = mid else: ng = mid mid = (ok + ng) // 2 if ok + 2 < ans: ans = ok ans_k = k ANS = [1] * 3 ANS[ans_k] = ans print(*ANS) if __name__ == '__main__': main()