답안 #142971

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
142971 2019-08-12T13:10:50 Z shayan_p Gap (APIO16_gap) C++14
100 / 100
75 ms 4068 KB
// only miss the sun when it starts to snow

#include<bits/stdc++.h>

#include "gap.h"

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll inf=1e18;

vector<ll> v1, v2, vec;

ll findGap(int t,int n){
    ll ans=-1;
    if(t==1){
	ll l=0, r=inf;
	while(sz(v1) + sz(v2) < n){
	    ll f,s; MinMax(l,r,&f,&s);
	    v1.PB(f), v2.PB(s);
	    l=f+1, r=s-1;
	}
	vec=v1;
	reverse(v2.begin(), v2.end());
	for(ll x:v2) vec.PB(x);
    }
    else{
	ll l,r; MinMax(0,inf,&l,&r);
	ll X=r-l, Y=X/(n-1);
	ans= (X+(n-2)) / (n-1);
	for(int i=0;i<n;i++){
	    v1.PB(l + Y*i);
	}
	int cnt=r-v1.back();
	for(int i=n-1;i>=0;i--){
	    v1[i]+=cnt;
	    if(cnt>0) cnt--;
	}
	for(int i=0;i<sz(v1);i++){
	    v1[i]++;
	}
	v1[0]--;
	for(int i=1;i<n;i++){
	    ll a,b; MinMax(v1[i-1],v1[i]-1,&a,&b);
	    if(a!=-1) vec.PB(a), vec.PB(b);
	}
    }
    for(int i=1;i<sz(vec);i++){
	ans=max(ans, vec[i] - vec[i-1]);
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 15 ms 1148 KB Output is correct
17 Correct 15 ms 1148 KB Output is correct
18 Correct 16 ms 1120 KB Output is correct
19 Correct 16 ms 1168 KB Output is correct
20 Correct 12 ms 1148 KB Output is correct
21 Correct 57 ms 2848 KB Output is correct
22 Correct 56 ms 3000 KB Output is correct
23 Correct 56 ms 2844 KB Output is correct
24 Correct 56 ms 2840 KB Output is correct
25 Correct 48 ms 2844 KB Output is correct
26 Correct 56 ms 2860 KB Output is correct
27 Correct 57 ms 2848 KB Output is correct
28 Correct 56 ms 2844 KB Output is correct
29 Correct 56 ms 2848 KB Output is correct
30 Correct 42 ms 2844 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 20 ms 1268 KB Output is correct
17 Correct 20 ms 1140 KB Output is correct
18 Correct 21 ms 1140 KB Output is correct
19 Correct 20 ms 1140 KB Output is correct
20 Correct 11 ms 1016 KB Output is correct
21 Correct 75 ms 3564 KB Output is correct
22 Correct 74 ms 3436 KB Output is correct
23 Correct 74 ms 3436 KB Output is correct
24 Correct 74 ms 3440 KB Output is correct
25 Correct 71 ms 4068 KB Output is correct
26 Correct 75 ms 3384 KB Output is correct
27 Correct 74 ms 3432 KB Output is correct
28 Correct 75 ms 3432 KB Output is correct
29 Correct 75 ms 3436 KB Output is correct
30 Correct 40 ms 2288 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct