結果

問題 No.1194 Replace
ユーザー 37zigen
提出日時 2020-08-31 17:29:08
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 257 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 48,752 KB
最終ジャッジ日時 2024-11-16 09:01:41
合計ジャッジ時間 22,928 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
A=[]
for i in range(M):
    B,C=map(int,input().split())
    A.append((-C,B))
A.sort()

m=dict()
ans=N*(N+1)//2
for c,b in A:
    c=-c
    if c in m:
        c=m[c]
    if c<b:
        continue
    m[b]=c
    ans+=c-b
print(ans)
0