답안 #979199

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979199 2024-05-10T11:22:10 Z starchan Gap (APIO16_gap) C++17
100 / 100
42 ms 3876 KB
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
#define in pair<int, int>
#define int long long
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)2e18
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
 
int findgap1(int n)
{
	vector<int> a(n);
	int l = 0;
	int r = n-1;
	int cl = 0;
	int cr = 1e18;
	while(l <= r)
	{
		int x, y;
		MinMax(cl, cr, &x, &y);
		cl = x+1;
		cr = y-1;
		a[l++] = x;
		a[r--] = y;
	}
	int ok = 0;
	for(int i = 0; i < n-1; i++)
		ok = max(ok, a[i+1]-a[i]);
	return ok;
}
 
int findgap2(int n)
{
	int mn, mx;
	MinMax(0, 1e18, &mn, &mx);
	int d = (mx-mn)/(n-1);
	if((mx-mn)%(n-1))
		d++;
	//answer is >= d.
	int prev = mn; int ans = d;
	for(int t = mn+1; t < mx; t+=d)
	{
		int x, y;
		MinMax(t, t+d-1, &x, &y);
		if(x != -1)
		{
			ans = max(ans, x-prev);
			prev = y;
		}
	}
	return ans;
}
 
//dummy real function
int findGap(signed T, signed n)
{
	int t = T;
	int N = n;
	if(t == 1)
		return findgap1(n);
	else
		return findgap2(n); 	 
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:63:6: warning: unused variable 'N' [-Wunused-variable]
   63 |  int N = n;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 2 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 2 ms 2392 KB Output is correct
14 Correct 1 ms 2552 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 8 ms 2584 KB Output is correct
17 Correct 8 ms 2588 KB Output is correct
18 Correct 8 ms 2584 KB Output is correct
19 Correct 8 ms 2588 KB Output is correct
20 Correct 6 ms 2604 KB Output is correct
21 Correct 29 ms 3876 KB Output is correct
22 Correct 30 ms 3544 KB Output is correct
23 Correct 32 ms 3632 KB Output is correct
24 Correct 30 ms 3624 KB Output is correct
25 Correct 27 ms 3812 KB Output is correct
26 Correct 30 ms 3624 KB Output is correct
27 Correct 30 ms 3616 KB Output is correct
28 Correct 31 ms 3872 KB Output is correct
29 Correct 30 ms 3624 KB Output is correct
30 Correct 27 ms 3620 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2500 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 11 ms 2588 KB Output is correct
17 Correct 10 ms 2588 KB Output is correct
18 Correct 10 ms 2580 KB Output is correct
19 Correct 10 ms 2752 KB Output is correct
20 Correct 5 ms 2572 KB Output is correct
21 Correct 40 ms 3104 KB Output is correct
22 Correct 40 ms 2852 KB Output is correct
23 Correct 40 ms 2852 KB Output is correct
24 Correct 42 ms 2868 KB Output is correct
25 Correct 38 ms 2856 KB Output is correct
26 Correct 41 ms 2860 KB Output is correct
27 Correct 40 ms 2852 KB Output is correct
28 Correct 42 ms 3060 KB Output is correct
29 Correct 41 ms 2860 KB Output is correct
30 Correct 23 ms 2860 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct