結果

問題 No.2403 "Eight" Bridges of Königsberg
ユーザー MottchanMottchan
提出日時 2023-08-04 22:47:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 118,444 KB
最終ジャッジ日時 2024-04-22 21:07:43
合計ジャッジ時間 5,760 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
54,784 KB
testcase_01 AC 48 ms
54,656 KB
testcase_02 AC 49 ms
54,912 KB
testcase_03 AC 48 ms
54,400 KB
testcase_04 AC 123 ms
77,184 KB
testcase_05 AC 186 ms
79,804 KB
testcase_06 AC 214 ms
80,656 KB
testcase_07 AC 132 ms
77,824 KB
testcase_08 AC 152 ms
78,960 KB
testcase_09 AC 190 ms
80,108 KB
testcase_10 AC 175 ms
78,804 KB
testcase_11 AC 155 ms
78,836 KB
testcase_12 AC 174 ms
79,360 KB
testcase_13 AC 158 ms
79,360 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 48 ms
54,400 KB
testcase_19 AC 129 ms
118,400 KB
testcase_20 AC 69 ms
72,320 KB
testcase_21 AC 100 ms
91,904 KB
testcase_22 AC 122 ms
112,512 KB
testcase_23 AC 107 ms
105,600 KB
testcase_24 AC 105 ms
101,760 KB
testcase_25 AC 102 ms
97,664 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 115 ms
105,600 KB
testcase_29 WA -
testcase_30 AC 88 ms
86,272 KB
testcase_31 AC 125 ms
114,816 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0