답안 #238599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238599 2020-06-12T06:45:20 Z denniskim Gap (APIO16_gap) C++14
100 / 100
87 ms 3392 KB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

long long findGap(int T, int N)
{
	vector<ll> vec;
	ll ret = 0;
	
	if(T == 1)
	{
		ll s = 0;
		ll e = 2000000000000000010;
		
		while(N >= 1)
		{
			ll minn, maxx;
			MinMax(s, e, &minn, &maxx);
			
			vec.push_back(minn);
			vec.push_back(maxx);
			
			s = minn + 1;
			e = maxx - 1;
			N -= 2;
		}
	}
	
	else
	{
		ll maxx, minn;
		MinMax(0, 2000000000000000010, &minn, &maxx);
		
		ll ho = (maxx - minn + N - 2) / (N - 1);
		ret = ho;
		
		for(ll p = minn ; p <= maxx ; p += ho + 1)
		{
			ll l, r;
			MinMax(p, p + ho, &l, &r);
			vec.push_back(l);
			vec.push_back(r);
		}
	}
	
	sort(vec.begin(), vec.end());
	
	for(int i = 1 ; i < vec.size() ; i++)
		ret = max(ret, vec[i] - vec[i - 1]);
	
	return ret;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:50:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1 ; i < vec.size() ; i++)
                  ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 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 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 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 6 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 21 ms 896 KB Output is correct
17 Correct 20 ms 1024 KB Output is correct
18 Correct 18 ms 896 KB Output is correct
19 Correct 20 ms 888 KB Output is correct
20 Correct 14 ms 1024 KB Output is correct
21 Correct 60 ms 2216 KB Output is correct
22 Correct 64 ms 2264 KB Output is correct
23 Correct 70 ms 2336 KB Output is correct
24 Correct 77 ms 2288 KB Output is correct
25 Correct 51 ms 2288 KB Output is correct
26 Correct 63 ms 2288 KB Output is correct
27 Correct 63 ms 2276 KB Output is correct
28 Correct 59 ms 2288 KB Output is correct
29 Correct 59 ms 2336 KB Output is correct
30 Correct 46 ms 2276 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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 5 ms 384 KB Output is correct
6 Correct 5 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 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 6 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 22 ms 1276 KB Output is correct
17 Correct 22 ms 1148 KB Output is correct
18 Correct 25 ms 1148 KB Output is correct
19 Correct 22 ms 1276 KB Output is correct
20 Correct 13 ms 1148 KB Output is correct
21 Correct 78 ms 3308 KB Output is correct
22 Correct 78 ms 3264 KB Output is correct
23 Correct 87 ms 3284 KB Output is correct
24 Correct 79 ms 3292 KB Output is correct
25 Correct 71 ms 3308 KB Output is correct
26 Correct 80 ms 3260 KB Output is correct
27 Correct 83 ms 3292 KB Output is correct
28 Correct 81 ms 3296 KB Output is correct
29 Correct 81 ms 3292 KB Output is correct
30 Correct 43 ms 3392 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 4 ms 384 KB Output is correct