답안 #107342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
107342 2019-04-23T11:40:50 Z maruii Gap (APIO16_gap) C++14
100 / 100
77 ms 3352 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

long long findGap(int T, int N){
	long long mn, mx, s=0, e=1e18, ans = 0;
	if(T==1){
		int i=0, j=N-1;
		vector<long long> vec(N);
		while(i<=j){
			MinMax(s, e, &mn, &mx);
			vec[i++] = mn, vec[j--] = mx;
			s = mn+1, e = mx-1;
		}
		for(int i=1; i<N; ++i) ans = max(ans, abs(vec[i]-vec[i-1]));
		return ans;
	}
	MinMax(0, 1e18, &mn, &mx);
	s = mn, e = mx;
	if(N==2) return e-s;
	long long d = (e-s-1)/(N-1)+1;
	vector<pair<long long, long long> > vec;
	vec.emplace_back(s, s);
	for(int i=1; i<N; ++i){
		MinMax(s+1+(i-1)*d, s+1+i*d-1, &mn, &mx);
		if(mn != -1) vec.emplace_back(mn, mx);
	}
	for(int i=1; i<vec.size(); ++i) ans = max(ans, vec[i].first - vec[i-1].second);
	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:28:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1; i<vec.size(); ++i) ans = max(ans, vec[i].first - vec[i-1].second);
               ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 14 ms 768 KB Output is correct
17 Correct 15 ms 768 KB Output is correct
18 Correct 14 ms 768 KB Output is correct
19 Correct 19 ms 768 KB Output is correct
20 Correct 11 ms 768 KB Output is correct
21 Correct 51 ms 1912 KB Output is correct
22 Correct 64 ms 1912 KB Output is correct
23 Correct 64 ms 1912 KB Output is correct
24 Correct 56 ms 2020 KB Output is correct
25 Correct 41 ms 1920 KB Output is correct
26 Correct 75 ms 1904 KB Output is correct
27 Correct 51 ms 1912 KB Output is correct
28 Correct 54 ms 1912 KB Output is correct
29 Correct 53 ms 1912 KB Output is correct
30 Correct 40 ms 1892 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 428 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 17 ms 896 KB Output is correct
17 Correct 20 ms 896 KB Output is correct
18 Correct 19 ms 1024 KB Output is correct
19 Correct 19 ms 896 KB Output is correct
20 Correct 10 ms 640 KB Output is correct
21 Correct 70 ms 2288 KB Output is correct
22 Correct 64 ms 2288 KB Output is correct
23 Correct 65 ms 2288 KB Output is correct
24 Correct 65 ms 2288 KB Output is correct
25 Correct 72 ms 3352 KB Output is correct
26 Correct 77 ms 2288 KB Output is correct
27 Correct 73 ms 2288 KB Output is correct
28 Correct 71 ms 2288 KB Output is correct
29 Correct 67 ms 2260 KB Output is correct
30 Correct 39 ms 1528 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct