結果

問題 No.1194 Replace
ユーザー titiatitia
提出日時 2020-08-22 16:41:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 580 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 47,488 KB
最終ジャッジ日時 2024-04-23 10:41:30
合計ジャッジ時間 12,810 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 587 ms
47,372 KB
testcase_08 AC 574 ms
47,308 KB
testcase_09 AC 589 ms
47,460 KB
testcase_10 AC 568 ms
47,488 KB
testcase_11 AC 590 ms
47,304 KB
testcase_12 AC 603 ms
47,296 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 27 ms
10,752 KB
testcase_21 AC 27 ms
10,752 KB
testcase_22 AC 29 ms
10,624 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from operator import itemgetter

N,M=map(int,input().split())
E=[tuple(map(int,input().split())) for i in range(M)]
E.sort(key=itemgetter(1),reverse=True)
SCORE=dict()

for x,y in E:
    if x in SCORE and y in SCORE:
        if SCORE[x]<SCORE[y]:
            SCORE[x]=SCORE[y]
    elif x in SCORE:
        if SCORE[x]<y:
            SCORE[x]=y
    elif y in SCORE:
        if x<SCORE[y]:
            SCORE[x]=SCORE[y]
    else:
        if x<y:
            SCORE[x]=y

ANS=N*(N+1)//2

for x in SCORE:
    ANS+=SCORE[x]-x

print(ANS)

        
0