結果

問題 No.2667 Constrained Permutation
ユーザー 👑 binapbinap
提出日時 2024-03-08 22:20:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,692 bytes
コンパイル時間 4,641 ms
コンパイル使用メモリ 267,868 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-08 22:20:56
合計ジャッジ時間 11,023 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 67 ms
6,676 KB
testcase_13 AC 4 ms
6,676 KB
testcase_14 AC 184 ms
6,676 KB
testcase_15 AC 151 ms
6,676 KB
testcase_16 AC 107 ms
6,676 KB
testcase_17 AC 35 ms
6,676 KB
testcase_18 AC 199 ms
6,676 KB
testcase_19 AC 195 ms
6,676 KB
testcase_20 AC 196 ms
6,676 KB
testcase_21 AC 196 ms
6,676 KB
testcase_22 AC 197 ms
6,676 KB
testcase_23 AC 195 ms
6,676 KB
testcase_24 AC 81 ms
6,676 KB
testcase_25 AC 154 ms
6,676 KB
testcase_26 AC 194 ms
6,676 KB
testcase_27 AC 187 ms
6,676 KB
testcase_28 AC 146 ms
6,676 KB
testcase_29 AC 138 ms
6,676 KB
testcase_30 AC 159 ms
6,676 KB
testcase_31 AC 95 ms
6,676 KB
testcase_32 AC 22 ms
6,676 KB
testcase_33 WA -
testcase_34 AC 103 ms
6,676 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 145 ms
6,676 KB
testcase_39 AC 4 ms
6,676 KB
testcase_40 AC 103 ms
6,676 KB
testcase_41 AC 162 ms
6,676 KB
testcase_42 AC 105 ms
6,676 KB
testcase_43 AC 150 ms
6,676 KB
testcase_44 AC 64 ms
6,676 KB
testcase_45 AC 4 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef long double ld;
typedef pair<int, int> P;

ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;}
template <int m> ostream& operator<<(ostream& os, const static_modint<m>& a) {os << a.val(); return os;}
template <int m> ostream& operator<<(ostream& os, const dynamic_modint<m>& a) {os << a.val(); return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;}
template<typename U, typename T> ostream& operator<<(ostream& os, const pair<U, T>& p){os << p.first << ' ' << p.second; return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;}

template<typename T> void chmin(T& a, T b){a = min(a, b);}
template<typename T> void chmax(T& a, T b){a = max(a, b);}

int main(){
	int n;
	cin >> n;
	vector<int> l(n), r(n);
	rep(i, n) cin >> l[i] >> r[i];
	int mn = 0;
	sort(l.begin(), l.end());
	rep(i, n){
		chmax(mn, l[i] - (i + 1));
	}
	int mx = 1001001001;
	sort(r.rbegin(), r.rend());
	rep(i, n){
		chmin(mx, r[i] - (n - i));
	}
//	cout << mn << ' ' << mx << "\n";
	int ans = max(mx - mn + 1, 0);
	cout << ans << "\n";
	return 0;
}
0