結果
問題 |
No.2403 "Eight" Bridges of Königsberg
|
ユーザー |
|
提出日時 | 2023-08-04 22:47:41 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 710 bytes |
コンパイル時間 | 651 ms |
コンパイル使用メモリ | 82,080 KB |
実行使用メモリ | 118,016 KB |
最終ジャッジ日時 | 2024-10-14 20:54:04 |
合計ジャッジ時間 | 5,223 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 WA * 10 |
ソースコード
import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd dout = defaultdict(int) din = defaultdict(int) n,m = map(int,input().split()) for i in range(m): a,b = map(int,input().split()) dout[b-1]+=1 din[a-1]+=1 cnt1=0 cnt2=0 c1max=0 c2max=0 for i in range(n): if dout[i] == din[i]: continue elif dout[i] > din[i]: cnt1+= dout[i] - din[i] c1max=max(cnt1,c1max) else: cnt2+= din[i] - dout[i] c2max=max(cnt1,c1max) if cnt1+cnt2 == 0: print(0) else: print((cnt1+cnt2)//2-1)