結果
問題 | No.2875 What is My Rank? |
ユーザー |
|
提出日時 | 2024-09-06 23:00:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 109 ms / 2,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 583 ms |
コンパイル使用メモリ | 68,800 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-06 23:02:43 |
合計ジャッジ時間 | 3,784 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include<iostream> #include<cassert> #include<atcoder/modint> using namespace std; using mint=atcoder::modint998244353; int N,L,R; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>L>>R;L--; const int off=1e9; R=off-R; L=off-L; swap(L,R); mint ans=1; for(int i=1;i<N;i++) { int l,r;cin>>l>>r;l--; r=off-r; l=off-l; swap(l,r); long long now=0; {//v+x long long lx=max(L,l+1),rx=min(R,r+1); if(lx<rx) { long long v=-l; now+=v*(rx-lx); now+=rx*(rx-1)/2; now-=lx*(lx-1)/2; } } {//r-l long long lx=max(L,r+1),rx=R; if(lx<rx)now+=(r-l)*(rx-lx); } ans+=now/mint(r-l)/mint(R-L); } cout<<ans.val()<<endl; }