結果

問題 No.2642 Don't cut line!
ユーザー ニックネームニックネーム
提出日時 2024-02-19 23:10:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 730 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 107,336 KB
最終ジャッジ日時 2024-02-19 23:10:28
合計ジャッジ時間 17,648 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 605 ms
107,332 KB
testcase_01 AC 612 ms
107,336 KB
testcase_02 AC 612 ms
107,208 KB
testcase_03 AC 619 ms
107,212 KB
testcase_04 AC 599 ms
107,212 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 335 ms
90,820 KB
testcase_08 AC 365 ms
91,056 KB
testcase_09 AC 340 ms
91,072 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 337 ms
91,076 KB
testcase_13 WA -
testcase_14 AC 356 ms
91,072 KB
testcase_15 AC 593 ms
107,228 KB
testcase_16 AC 536 ms
102,720 KB
testcase_17 AC 590 ms
105,380 KB
testcase_18 AC 448 ms
97,740 KB
testcase_19 AC 452 ms
92,504 KB
testcase_20 AC 405 ms
92,868 KB
testcase_21 AC 462 ms
99,300 KB
testcase_22 AC 606 ms
106,724 KB
testcase_23 AC 382 ms
91,784 KB
testcase_24 AC 409 ms
91,956 KB
testcase_25 WA -
testcase_26 AC 422 ms
96,648 KB
testcase_27 AC 553 ms
103,524 KB
testcase_28 WA -
testcase_29 AC 405 ms
92,628 KB
testcase_30 AC 507 ms
100,036 KB
testcase_31 AC 404 ms
92,324 KB
testcase_32 AC 32 ms
53,588 KB
testcase_33 AC 32 ms
53,588 KB
testcase_34 AC 32 ms
53,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class UF:
    def __init__(self,n):
        self.p = [-1]*n
    def f(self,x):
        if self.p[x]<0: return x
        else: self.p[x] = self.f(self.p[x]); return self.p[x]
    def u(self,x,y):
        x = self.f(x); y = self.f(y)
        if x==y: return
        if -self.p[x]<-self.p[y]: x,y = y,x
        self.p[x] += self.p[y]; self.p[y] = x
    def s(self,x,y): return self.f(x) == self.f(y)
n,k,c = map(int,input().split())
wpuv = []
for _ in range(k):
    u,v,w,p = map(int,input().split())
    wpuv.append((w,p,u-1,v-1))
uf = UF(n); adj = [[] for _ in range(n)]; d = m = 0
for w,p,u,v in sorted(wpuv):
    if not uf.s(u,v):
        uf.u(u,v); d += w; m = max(m,p)
        adj[u-1].append(w); adj[v-1].append(w)
e = [max(adj[i]) for i in range(n)]
if d>c: exit(print(-1))
for w,p,u,v in wpuv:
    if d-max(e[u],e[v])+w<=c: m = max(m,p)
print(m)
0