Submission #1792412


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,t[100005],a[100005],b[100005];
#define s (1<<18)
int seg[s]={};
void update(int k,int a){
	k+=s/2-1; seg[k]=a;
	while(k>0){
		k=(k-1)/2;
		seg[k]=max(seg[k*2+1],seg[k*2+2]);
	}
}
int query(int a,int b,int k,int l,int r){
	if(r<a || b<l) return 0;
	if(a<=l && r<=b) return seg[k];
	else{
		int vl=query(a,b,k*2+1,l,(l+r)/2);
		int vr=query(a,b,k*2+2,(l+r)/2+1,r);
		return max(vl,vr);
	}
}
int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
		t[a[i]]++; t[b[i]]--;
	}
	repn(i,100000) t[i] += t[i-1];
	repn(i,100000){
		update(i,t[i]);
	}
	int ans = INF;
	rep(i,n){
		int hoge = 0;
		hoge = max(hoge,query(1,a[i]-1,0,0,s/2-1));
		hoge = max(hoge,query(b[i],s/2-1,0,0,s/2-1));
		hoge = max(hoge,query(a[i],b[i]-1,0,0,s/2-1)-1);
		ans = min(ans,hoge);
	}
	cout << ans << endl;
}

Submission Info

Submission Time
Task D - 足ゲームII
User IH19980412
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1437 Byte
Status AC
Exec Time 158 ms
Memory 2176 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 34
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
All sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt AC 6 ms 1408 KB
01-02.txt AC 6 ms 1408 KB
01-03.txt AC 6 ms 1408 KB
01-04.txt AC 8 ms 1408 KB
01-05.txt AC 156 ms 2176 KB
01-06.txt AC 158 ms 2176 KB
01-07.txt AC 156 ms 2176 KB
01-08.txt AC 157 ms 2176 KB
01-09.txt AC 156 ms 2176 KB
01-10.txt AC 6 ms 1408 KB
01-11.txt AC 157 ms 2176 KB
01-12.txt AC 156 ms 2176 KB
01-13.txt AC 157 ms 2176 KB
01-14.txt AC 156 ms 2176 KB
01-15.txt AC 9 ms 1408 KB
01-16.txt AC 157 ms 2176 KB
01-17.txt AC 156 ms 2176 KB
01-18.txt AC 157 ms 2176 KB
01-19.txt AC 156 ms 2176 KB
01-20.txt AC 9 ms 1408 KB
01-21.txt AC 155 ms 2176 KB
01-22.txt AC 155 ms 2176 KB
01-23.txt AC 155 ms 2176 KB
01-24.txt AC 110 ms 2176 KB
01-25.txt AC 6 ms 1408 KB
01-26.txt AC 6 ms 1408 KB
01-27.txt AC 141 ms 2176 KB
01-28.txt AC 142 ms 2176 KB
sample-01.txt AC 6 ms 1408 KB
sample-02.txt AC 6 ms 1408 KB
sample-03.txt AC 6 ms 1408 KB