Submission #107337

# Submission time Handle Problem Language Result Execution time Memory
107337 2019-04-23T11:20:28 Z maruii Gap (APIO16_gap) C++14
30 / 100
83 ms 3276 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;
	bool flag = 1;
	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);
			if(i==1) ans = max(ans, mn-s);
		}
		else flag = 0;
	}
	if(flag) return d;
	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:33: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);
               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 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 2 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 15 ms 768 KB Output is correct
17 Correct 15 ms 768 KB Output is correct
18 Correct 15 ms 704 KB Output is correct
19 Correct 15 ms 768 KB Output is correct
20 Correct 12 ms 768 KB Output is correct
21 Correct 49 ms 1920 KB Output is correct
22 Correct 62 ms 1912 KB Output is correct
23 Correct 58 ms 1912 KB Output is correct
24 Correct 52 ms 1884 KB Output is correct
25 Correct 49 ms 1920 KB Output is correct
26 Correct 50 ms 1920 KB Output is correct
27 Correct 51 ms 1912 KB Output is correct
28 Correct 55 ms 1884 KB Output is correct
29 Correct 50 ms 1892 KB Output is correct
30 Correct 37 ms 1920 KB Output is correct
31 Correct 3 ms 300 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory 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 3 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 3 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 384 KB Output is correct
11 Correct 3 ms 356 KB Output is correct
12 Correct 3 ms 304 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 412 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 18 ms 888 KB Output is correct
17 Correct 24 ms 888 KB Output is correct
18 Correct 20 ms 868 KB Output is correct
19 Correct 17 ms 876 KB Output is correct
20 Correct 9 ms 512 KB Output is correct
21 Correct 69 ms 2220 KB Output is correct
22 Correct 68 ms 2412 KB Output is correct
23 Correct 68 ms 2256 KB Output is correct
24 Correct 77 ms 2388 KB Output is correct
25 Correct 72 ms 3276 KB Output is correct
26 Correct 75 ms 2384 KB Output is correct
27 Correct 83 ms 2332 KB Output is correct
28 Correct 70 ms 2160 KB Output is correct
29 Correct 72 ms 2260 KB Output is correct
30 Correct 37 ms 1536 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Incorrect 3 ms 384 KB Output isn't correct