結果

問題 No.2875 What is My Rank?
ユーザー 沙耶花沙耶花
提出日時 2024-09-06 22:08:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 748 bytes
コンパイル時間 4,093 ms
コンパイル使用メモリ 262,464 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-06 22:08:56
合計ジャッジ時間 8,342 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 220 ms
6,944 KB
testcase_34 AC 166 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0