結果

問題 No.2667 Constrained Permutation
ユーザー inksamuraiinksamurai
提出日時 2024-03-08 23:32:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,365 bytes
コンパイル時間 2,144 ms
コンパイル使用メモリ 212,080 KB
実行使用メモリ 11,060 KB
最終ジャッジ日時 2024-03-08 23:33:18
合計ジャッジ時間 19,486 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 4 ms
6,676 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
6,676 KB
testcase_08 WA -
testcase_09 AC 9 ms
6,676 KB
testcase_10 WA -
testcase_11 AC 7 ms
6,676 KB
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 AC 506 ms
9,060 KB
testcase_29 AC 495 ms
8,800 KB
testcase_30 AC 537 ms
9,508 KB
testcase_31 AC 330 ms
7,040 KB
testcase_32 AC 66 ms
6,676 KB
testcase_33 AC 642 ms
10,852 KB
testcase_34 AC 354 ms
7,368 KB
testcase_35 AC 407 ms
7,980 KB
testcase_36 AC 385 ms
7,748 KB
testcase_37 AC 440 ms
8,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 348 ms
7,352 KB
testcase_41 AC 556 ms
9,716 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) ((int) a.size())
#define vec(...) vector<__VA_ARGS__>
#define _3TpP2FO ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}

void slv(){
	int n;
	cin>>n;

	vec(pii) a(n);
	rep(i,n){
		cin>>a[i].fi>>a[i].se;
	}

	int mi=1e9;
	rep(i,n){
		mi=min(mi,a[i].fi);
	}
	// mi - k = 1
	// k = mi - 1
	auto af=[&](int k)->int{
		vec(vi) adqry(n+1);
		rep(i,n){
			auto [l,r]=a[i];
			l-=k,r-=k;
			if(r<0){
				return 0;
			}
			if(l>n){
				return 0;
			}
			l=max(l,1ll);
			r=min(r,n);
			if(l>r){
				return 0;
			}
			adqry[l].pb(r);
		}
		multiset<int> mst;
		rng(i,1,n+1){
			while(sz(mst) and *mst.begin()<i){
				mst.erase(mst.begin());
			}
			for(auto r:adqry[i]){
				mst.insert(r);
			}
			if(!sz(mst)){
				return 0;
			}
			auto it=mst.begin();
			mst.erase(it);
		}
		return 1;
	};
	int ans=0;
	rep(k,1000){
		if(af(k)){
			// print(k);
			ans++;
		}
	}
	print(ans);
}

signed main(){
_3TpP2FO;
	slv();
}
0