답안 #237883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237883 2020-06-09T07:41:43 Z Evirir Gap (APIO16_gap) C++17
100 / 100
83 ms 1984 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "gap.h"
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }

#define MAXN 100005

ll mn,mx;

ll findGap(int T, int n)
{
	if(T==1)
	{
		ll L=0,R=1e18;
		ll a[n];
		for(int i=0;i<(n+1)/2;i++){
			MinMax(L,R,&mn,&mx);
			a[i]=mn, a[n-1-i]=mx;
			L=mn+1, R=mx-1;
		}
		ll ans=0;
		forn(i,0,n-1) ans=max(ans, a[i+1]-a[i]);
		return ans;
	}
	
	else
	{
		ll L,R,ans=0;
		MinMax(0,1e18,&L,&R);
		ll len=(R-L)/(n-1);
		ll pre=L;
		for(ll i=L+1;i<=R;i+=len+1){
			MinMax(i,i+len,&mn,&mx);
			if(mn!=-1){
				ans=max(ans, mn-pre);
				pre=mx;
			}
		}
		return ans;
	}
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 16 ms 768 KB Output is correct
17 Correct 17 ms 768 KB Output is correct
18 Correct 16 ms 768 KB Output is correct
19 Correct 17 ms 768 KB Output is correct
20 Correct 13 ms 768 KB Output is correct
21 Correct 62 ms 1912 KB Output is correct
22 Correct 57 ms 1912 KB Output is correct
23 Correct 63 ms 1984 KB Output is correct
24 Correct 57 ms 1912 KB Output is correct
25 Correct 51 ms 1980 KB Output is correct
26 Correct 61 ms 1912 KB Output is correct
27 Correct 55 ms 1912 KB Output is correct
28 Correct 55 ms 1888 KB Output is correct
29 Correct 54 ms 1960 KB Output is correct
30 Correct 43 ms 1912 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 436 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 20 ms 512 KB Output is correct
17 Correct 20 ms 512 KB Output is correct
18 Correct 20 ms 512 KB Output is correct
19 Correct 21 ms 512 KB Output is correct
20 Correct 12 ms 512 KB Output is correct
21 Correct 80 ms 1144 KB Output is correct
22 Correct 73 ms 1144 KB Output is correct
23 Correct 72 ms 1144 KB Output is correct
24 Correct 74 ms 1120 KB Output is correct
25 Correct 66 ms 1144 KB Output is correct
26 Correct 74 ms 1272 KB Output is correct
27 Correct 83 ms 1144 KB Output is correct
28 Correct 79 ms 1148 KB Output is correct
29 Correct 70 ms 1144 KB Output is correct
30 Correct 46 ms 1272 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct