結果
問題 | No.2875 What is My Rank? |
ユーザー |
![]() |
提出日時 | 2024-09-06 23:12:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 408 ms / 2,000 ms |
コード長 | 436 bytes |
コンパイル時間 | 306 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 77,088 KB |
最終ジャッジ日時 | 2024-09-06 23:12:23 |
合計ジャッジ時間 | 7,982 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
N = int(input()) mod = 998244353 ans = 1 L,R = map(int,input().split()) D = R - L + 1 for i in range(1,N): l,r = map(int,input().split()) if R < l: ans += 1 continue elif r < L: continue ll = max(l,L) rr = min(r,R) d = r - l + 1 n = rr - ll + 1 res = (2 * r - ll - rr) * n res //= 2 res = res * pow(d,-1,mod) % mod res += (ll - L) res = res * pow(D,-1,mod) % mod ans = (ans + res) % mod print(ans)