답안 #469951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
469951 2021-09-02T11:53:24 Z jazzup Gap (APIO16_gap) C++14
100 / 100
72 ms 2232 KB
#include "gap.h"
#include<vector>
#include<algorithm>

using namespace std;

vector<long long> v;

long long st=0,ed=1e18;

long long findGap(int T, int N){
	if(T==1){
		long long mn=st,mx=ed;
		for(int i=0;i<(N+1)/2;i++){
			MinMax(mn,mx,&mn,&mx);
			v.push_back(mn);
			if(mx!=mn)v.push_back(mx);
			mn++;
			mx--;
		}
		sort(v.begin(),v.end());
		long long ans=0;
		for(int i=0;i<v.size()-1;i++){
			ans=max(ans,v[i+1]-v[i]);
		}
		return ans;
	}

	long long mn,mx;
	MinMax(st,ed,&mn,&mx);

	if (N == 2) return mx-mn;

	long long ga=mx-mn-1;

	long long s=mn+1,rec=mn,ans=0;

	for(int i=0;i<N;i++){
		MinMax(s,s+1+ga/(N-1),&mn,&mx);
		if(mn!=-1){
			ans=max(ans,mn-rec);
			rec=mx;
		}
		s=s+2+ga/(N-1);
	}
	return ans;

}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for(int i=0;i<v.size()-1;i++){
      |               ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 14 ms 840 KB Output is correct
17 Correct 12 ms 868 KB Output is correct
18 Correct 15 ms 840 KB Output is correct
19 Correct 15 ms 840 KB Output is correct
20 Correct 11 ms 840 KB Output is correct
21 Correct 55 ms 2200 KB Output is correct
22 Correct 50 ms 2104 KB Output is correct
23 Correct 49 ms 2172 KB Output is correct
24 Correct 50 ms 2188 KB Output is correct
25 Correct 44 ms 2184 KB Output is correct
26 Correct 49 ms 2232 KB Output is correct
27 Correct 48 ms 2168 KB Output is correct
28 Correct 48 ms 2228 KB Output is correct
29 Correct 48 ms 2180 KB Output is correct
30 Correct 44 ms 2232 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 14 ms 456 KB Output is correct
17 Correct 16 ms 496 KB Output is correct
18 Correct 16 ms 576 KB Output is correct
19 Correct 15 ms 512 KB Output is correct
20 Correct 7 ms 456 KB Output is correct
21 Correct 59 ms 1056 KB Output is correct
22 Correct 72 ms 1040 KB Output is correct
23 Correct 59 ms 1036 KB Output is correct
24 Correct 59 ms 1024 KB Output is correct
25 Correct 55 ms 968 KB Output is correct
26 Correct 59 ms 960 KB Output is correct
27 Correct 58 ms 960 KB Output is correct
28 Correct 61 ms 960 KB Output is correct
29 Correct 58 ms 1056 KB Output is correct
30 Correct 37 ms 964 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct