답안 #409792

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409792 2021-05-21T14:26:37 Z jeqcho Gap (APIO16_gap) C++17
100 / 100
76 ms 3256 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define fi first
#define se second

long long findGap(int T, int N)
{
	if(T==1)
	{
		ll s=0;
		ll t=1e18;
		vector<ll>v;
		while(sz(v)!=N)
		{
			ll c,d;
			MinMax(s,t,&c,&d);
			v.pb(c);
			if(c!=d)v.pb(d);
			s=c+1;
			t=d-1;
		}
		sort(all(v));
		ll rec=-1e9;
		F0R(i,N-1)
		{
			rec=max(rec,v[i+1]-v[i]);
		}
		return rec;
	}
	else
	{
		ll s=0;
		ll t=1e18;
		vector<ll>v;
		ll a,b;
		MinMax(s,t,&a,&b);
		ll lef=a;
		ll rig=b;
		v.pb(a);
		v.pb(b);
		ll len =(b-1 - (a-1)+1)/(N-1) + 1;
		s=a+1;
		t=a+1+len-1;
		while(1)
		{
			MinMax(s,t,&a,&b);
			v.pb(a);
			v.pb(b);
			if(t==rig)break;
			s=t+1;
			t=s+len-1;
			t=min(t,rig);
			if(s>t)break;
		}
		sort(all(v));
		ll rec=-1e9;
		F0R(i,sz(v)-1)
		{
			rec=max(rec,v[i+1]-v[i]);
		}
		return rec;
	}
	
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:54:6: warning: unused variable 'lef' [-Wunused-variable]
   54 |   ll lef=a;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 2 ms 328 KB Output is correct
12 Correct 2 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 13 ms 888 KB Output is correct
17 Correct 13 ms 808 KB Output is correct
18 Correct 16 ms 816 KB Output is correct
19 Correct 14 ms 840 KB Output is correct
20 Correct 12 ms 840 KB Output is correct
21 Correct 56 ms 2236 KB Output is correct
22 Correct 49 ms 2224 KB Output is correct
23 Correct 49 ms 2232 KB Output is correct
24 Correct 51 ms 2192 KB Output is correct
25 Correct 48 ms 2208 KB Output is correct
26 Correct 57 ms 2172 KB Output is correct
27 Correct 57 ms 2200 KB Output is correct
28 Correct 55 ms 2252 KB Output is correct
29 Correct 50 ms 2232 KB Output is correct
30 Correct 45 ms 2196 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 2 ms 328 KB Output is correct
12 Correct 2 ms 328 KB Output is correct
13 Correct 2 ms 300 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 17 ms 1092 KB Output is correct
17 Correct 18 ms 1092 KB Output is correct
18 Correct 19 ms 1092 KB Output is correct
19 Correct 20 ms 1104 KB Output is correct
20 Correct 12 ms 1092 KB Output is correct
21 Correct 76 ms 3252 KB Output is correct
22 Correct 70 ms 3256 KB Output is correct
23 Correct 73 ms 3176 KB Output is correct
24 Correct 71 ms 3252 KB Output is correct
25 Correct 63 ms 3220 KB Output is correct
26 Correct 70 ms 3248 KB Output is correct
27 Correct 71 ms 3236 KB Output is correct
28 Correct 72 ms 3216 KB Output is correct
29 Correct 72 ms 3152 KB Output is correct
30 Correct 40 ms 3236 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct