結果

問題 No.2667 Constrained Permutation
ユーザー kotatsugamekotatsugame
提出日時 2024-03-08 21:29:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 620 bytes
コンパイル時間 836 ms
コンパイル使用メモリ 78,812 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-08 21:29:08
合計ジャッジ時間 4,670 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 28 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 78 ms
6,676 KB
testcase_15 AC 58 ms
6,676 KB
testcase_16 AC 41 ms
6,676 KB
testcase_17 AC 15 ms
6,676 KB
testcase_18 AC 85 ms
6,676 KB
testcase_19 AC 83 ms
6,676 KB
testcase_20 AC 110 ms
6,676 KB
testcase_21 AC 73 ms
6,676 KB
testcase_22 AC 74 ms
6,676 KB
testcase_23 AC 74 ms
6,676 KB
testcase_24 AC 35 ms
6,676 KB
testcase_25 AC 68 ms
6,676 KB
testcase_26 AC 85 ms
6,676 KB
testcase_27 AC 82 ms
6,676 KB
testcase_28 AC 56 ms
6,676 KB
testcase_29 AC 53 ms
6,676 KB
testcase_30 AC 58 ms
6,676 KB
testcase_31 AC 36 ms
6,676 KB
testcase_32 AC 9 ms
6,676 KB
testcase_33 WA -
testcase_34 AC 39 ms
6,676 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 58 ms
6,676 KB
testcase_39 AC 3 ms
6,676 KB
testcase_40 AC 41 ms
6,676 KB
testcase_41 AC 65 ms
6,676 KB
testcase_42 AC 47 ms
6,676 KB
testcase_43 AC 68 ms
6,676 KB
testcase_44 AC 27 ms
6,676 KB
testcase_45 AC 3 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;cin>>N;
	vector<pair<int,int> >LR(N);
	for(int i=0;i<N;i++)cin>>LR[i].first>>LR[i].second;
	sort(LR.begin(),LR.end());
	int lk=-2e9;
	for(int i=0;i<N;i++)
	{
		int l=LR[i].first;
		//l<=k+i+1 <=> l-i-1<=k
		lk=max(lk,l-i-1);
	}
	sort(LR.begin(),LR.end(),[](pair<int,int>l,pair<int,int>r){return l.second<r.second;});
	int rk=2e9;
	for(int i=0;i<N;i++)
	{
		int r=LR[i].second;
		//k+i+1<=r <=> k<=r-i-1
		rk=min(rk,r-i-1);
	}
	cout<<max(0,rk-lk+1)<<endl;
}
0