結果
問題 | No.1898 Battle and Exchange |
ユーザー | tamato |
提出日時 | 2022-04-08 23:22:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,185 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 81,720 KB |
実行使用メモリ | 187,168 KB |
最終ジャッジ日時 | 2024-11-28 14:33:19 |
合計ジャッジ時間 | 38,776 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
53,248 KB |
testcase_01 | AC | 43 ms
53,120 KB |
testcase_02 | AC | 44 ms
52,864 KB |
testcase_03 | WA | - |
testcase_04 | AC | 59 ms
63,872 KB |
testcase_05 | AC | 59 ms
64,000 KB |
testcase_06 | AC | 108 ms
76,252 KB |
testcase_07 | WA | - |
testcase_08 | AC | 83 ms
73,856 KB |
testcase_09 | AC | 148 ms
77,852 KB |
testcase_10 | AC | 44 ms
53,248 KB |
testcase_11 | AC | 63 ms
65,152 KB |
testcase_12 | AC | 59 ms
65,856 KB |
testcase_13 | AC | 44 ms
52,736 KB |
testcase_14 | AC | 65 ms
67,840 KB |
testcase_15 | AC | 45 ms
52,992 KB |
testcase_16 | AC | 79 ms
72,320 KB |
testcase_17 | AC | 178 ms
78,412 KB |
testcase_18 | AC | 370 ms
85,028 KB |
testcase_19 | AC | 603 ms
89,056 KB |
testcase_20 | AC | 357 ms
88,780 KB |
testcase_21 | AC | 989 ms
104,212 KB |
testcase_22 | AC | 59 ms
63,872 KB |
testcase_23 | AC | 58 ms
64,512 KB |
testcase_24 | AC | 67 ms
68,608 KB |
testcase_25 | AC | 95 ms
76,300 KB |
testcase_26 | AC | 43 ms
53,120 KB |
testcase_27 | AC | 100 ms
76,628 KB |
testcase_28 | AC | 103 ms
76,888 KB |
testcase_29 | AC | 114 ms
77,616 KB |
testcase_30 | AC | 93 ms
76,256 KB |
testcase_31 | AC | 52 ms
61,312 KB |
testcase_32 | AC | 355 ms
87,144 KB |
testcase_33 | AC | 660 ms
96,696 KB |
testcase_34 | AC | 284 ms
85,328 KB |
testcase_35 | AC | 430 ms
90,240 KB |
testcase_36 | WA | - |
testcase_37 | AC | 273 ms
82,968 KB |
testcase_38 | AC | 3,710 ms
187,168 KB |
testcase_39 | AC | 736 ms
143,740 KB |
testcase_40 | AC | 2,569 ms
156,728 KB |
testcase_41 | AC | 593 ms
135,968 KB |
testcase_42 | AC | 180 ms
77,996 KB |
testcase_43 | AC | 559 ms
104,076 KB |
testcase_44 | AC | 59 ms
63,104 KB |
testcase_45 | AC | 261 ms
79,488 KB |
testcase_46 | AC | 637 ms
88,096 KB |
testcase_47 | AC | 190 ms
78,524 KB |
testcase_48 | AC | 178 ms
80,424 KB |
testcase_49 | AC | 121 ms
77,116 KB |
testcase_50 | AC | 116 ms
76,788 KB |
testcase_51 | AC | 123 ms
77,056 KB |
testcase_52 | AC | 104 ms
77,020 KB |
testcase_53 | AC | 185 ms
79,764 KB |
testcase_54 | AC | 232 ms
80,896 KB |
testcase_55 | AC | 326 ms
82,924 KB |
testcase_56 | AC | 220 ms
82,344 KB |
testcase_57 | AC | 2,726 ms
112,968 KB |
testcase_58 | AC | 1,799 ms
111,516 KB |
testcase_59 | AC | 1,660 ms
113,144 KB |
testcase_60 | AC | 1,675 ms
110,656 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 # 頂点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, 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()