結果
問題 |
No.2875 What is My Rank?
|
ユーザー |
![]() |
提出日時 | 2024-09-06 22:02:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 747 bytes |
コンパイル時間 | 3,985 ms |
コンパイル使用メモリ | 250,656 KB |
最終ジャッジ日時 | 2025-02-24 04:21:42 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 6 WA * 26 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 int main(){ int N; cin>>N; int L,R; cin>>L>>R; mint ans = 1; rep(i,N-1){ int l,r; cin>>l>>r; if(l>=R)ans++; else if(L>r)continue; else{ int sl = max(L,l), sr = min(R,r); mint pp = (R-L+1); pp *= (r-l+1); { mint n =sr-sl+1; mint cnt = n * (n-1)/2; ans += cnt / pp; } if(L<sl){ mint p = R-L+1; ans += mint(sl-L) / p; } if(r>sr){ mint p = r-l+1; ans += mint(r-sr) / p; } } } cout<<ans.val()<<endl; return 0; }