Submission #107327

# Submission time Handle Problem Language Result Execution time Memory
107327 2019-04-23T10:53:45 Z maruii Gap (APIO16_gap) C++14
30 / 100
84 ms 4460 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;
	long long d = (e-s)/(N-1)+1;
	vector<pair<long long, long long> > vec;
	bool flag = 1;
	for(int i=1; i<N; ++i){
		MinMax(s+(i-1)*d, s+i*d-1, &mn, &mx);
		if(mn != -1) vec.emplace_back(mn, mx);
		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:29: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 3 ms 512 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 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 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 16 ms 1024 KB Output is correct
17 Correct 15 ms 1024 KB Output is correct
18 Correct 17 ms 1152 KB Output is correct
19 Correct 16 ms 1024 KB Output is correct
20 Correct 15 ms 768 KB Output is correct
21 Correct 53 ms 3580 KB Output is correct
22 Correct 55 ms 3576 KB Output is correct
23 Correct 49 ms 3576 KB Output is correct
24 Correct 51 ms 3704 KB Output is correct
25 Correct 44 ms 2912 KB Output is correct
26 Correct 54 ms 3704 KB Output is correct
27 Correct 48 ms 3576 KB Output is correct
28 Correct 68 ms 3608 KB Output is correct
29 Correct 53 ms 3704 KB Output is correct
30 Correct 40 ms 2420 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 284 KB Output isn't 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 Incorrect 2 ms 384 KB Output isn't 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 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 512 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 Incorrect 3 ms 512 KB Output isn't correct
16 Correct 18 ms 1412 KB Output is correct
17 Correct 17 ms 1280 KB Output is correct
18 Correct 21 ms 1256 KB Output is correct
19 Correct 20 ms 1280 KB Output is correct
20 Correct 10 ms 640 KB Output is correct
21 Correct 84 ms 4032 KB Output is correct
22 Correct 69 ms 4208 KB Output is correct
23 Correct 75 ms 4052 KB Output is correct
24 Correct 68 ms 4052 KB Output is correct
25 Incorrect 57 ms 4460 KB Output isn't correct
26 Correct 64 ms 4080 KB Output is correct
27 Correct 66 ms 3952 KB Output is correct
28 Correct 67 ms 3952 KB Output is correct
29 Correct 74 ms 4072 KB Output is correct
30 Correct 37 ms 2048 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct