답안 #262036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
262036 2020-08-12T09:55:40 Z Saboon Gap (APIO16_gap) C++14
100 / 100
79 ms 3308 KB
#include "gap.h"
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;


long long findGap(int T, int n){
	ll lo = 0, hi = 1'000'000'000'000'000'000LL;
	if (T == 1){
		int cnt = 0;
		vector<ll> a;
		while (hi > lo){
			ll mn, mx;
			cnt ++;
			if (cnt > (n+1)/2)
				break;
			MinMax(lo, hi, &mn, &mx);
			if (mn == -1)
				break;
			a.push_back(mn);
			a.push_back(mx);
			lo = mn + 1, hi = mx - 1;
		}
		sort(a.begin(), a.end());
		ll answer = 0;
		for (int i = 1; i < a.size(); i++)
			answer = max(answer, a[i]-a[i-1]);
		return answer;
	}
	ll mn, mx;
	MinMax(lo, hi, &mn, &mx);
	ll t = (mx-mn+n-2) / (n-1);
	vector<ll> a;
	lo = mn, hi = mx;
	for (ll i = lo; i <= hi; i += t+1){
		MinMax(i, i+t, &mn, &mx);
		if (mn == -1)
			continue;
		a.push_back(mn);
		a.push_back(mx);
	}
	ll answer = 0;
	for (int i = 1; i < a.size(); i++)
		answer = max(answer, a[i]-a[i-1]);
	return answer;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 1; i < a.size(); i++)
                   ~~^~~~~~~~~~
gap.cpp:44:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < a.size(); i++)
                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 14 ms 896 KB Output is correct
17 Correct 14 ms 896 KB Output is correct
18 Correct 14 ms 896 KB Output is correct
19 Correct 17 ms 896 KB Output is correct
20 Correct 10 ms 896 KB Output is correct
21 Correct 62 ms 2288 KB Output is correct
22 Correct 59 ms 2288 KB Output is correct
23 Correct 59 ms 2264 KB Output is correct
24 Correct 60 ms 2316 KB Output is correct
25 Correct 51 ms 2276 KB Output is correct
26 Correct 57 ms 2288 KB Output is correct
27 Correct 59 ms 2392 KB Output is correct
28 Correct 57 ms 2288 KB Output is correct
29 Correct 64 ms 2244 KB Output is correct
30 Correct 48 ms 2288 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 19 ms 896 KB Output is correct
17 Correct 17 ms 896 KB Output is correct
18 Correct 17 ms 896 KB Output is correct
19 Correct 17 ms 896 KB Output is correct
20 Correct 9 ms 620 KB Output is correct
21 Correct 69 ms 2288 KB Output is correct
22 Correct 79 ms 2320 KB Output is correct
23 Correct 71 ms 2228 KB Output is correct
24 Correct 72 ms 2468 KB Output is correct
25 Correct 69 ms 3308 KB Output is correct
26 Correct 79 ms 2288 KB Output is correct
27 Correct 78 ms 2288 KB Output is correct
28 Correct 69 ms 2328 KB Output is correct
29 Correct 72 ms 2288 KB Output is correct
30 Correct 35 ms 1532 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct