Submission #23002

# Submission time Handle Problem Language Result Execution time Memory
23002 2017-05-01T06:11:43 Z kdh9949 Gap (APIO16_gap) C++14
100 / 100
96 ms 7460 KB
#include "gap.h"
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;

vector<ll> v;
ll a = -1, b = (1LL << 62), c, x, y, ans;

ll findGap(int T, int N)
{
	if(T == 1){
        for(int i = 0; i < (N + 1) / 2; i++){
            MinMax(a + 1, b - 1, &a, &b);
            v.push_back(a); v.push_back(b);
        }
    }
	else{
		MinMax(a, b, &a, &b);
		v.push_back(a); v.push_back(b);
		c = b - a; N--;
		c = (c + N - 1) / N;
		for(int i = 0; i < N; i++){
			ll q = a + c * i + 1;
			ll w = a + c * (i + 1);
			MinMax(q, w, &x, &y);
			if(x == -1) continue;
			v.push_back(x); v.push_back(y);
		}
	}
	sort(v.begin(), v.end());
	for(int i = 1; i < v.size(); i++) ans = max(ans, v[i] - v[i - 1]);
	return ans;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:32:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1; i < v.size(); i++) ans = max(ans, v[i] - v[i - 1]);
                   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4300 KB Output is correct
2 Correct 0 ms 4300 KB Output is correct
3 Correct 0 ms 4300 KB Output is correct
4 Correct 0 ms 4300 KB Output is correct
5 Correct 0 ms 4300 KB Output is correct
6 Correct 0 ms 4300 KB Output is correct
7 Correct 0 ms 4300 KB Output is correct
8 Correct 0 ms 4300 KB Output is correct
9 Correct 0 ms 4300 KB Output is correct
10 Correct 0 ms 4300 KB Output is correct
11 Correct 0 ms 4300 KB Output is correct
12 Correct 0 ms 4300 KB Output is correct
13 Correct 0 ms 4300 KB Output is correct
14 Correct 0 ms 4300 KB Output is correct
15 Correct 0 ms 4300 KB Output is correct
16 Correct 9 ms 4772 KB Output is correct
17 Correct 9 ms 4772 KB Output is correct
18 Correct 13 ms 4772 KB Output is correct
19 Correct 13 ms 4772 KB Output is correct
20 Correct 6 ms 4772 KB Output is correct
21 Correct 46 ms 5924 KB Output is correct
22 Correct 56 ms 5924 KB Output is correct
23 Correct 69 ms 5924 KB Output is correct
24 Correct 56 ms 5924 KB Output is correct
25 Correct 49 ms 5924 KB Output is correct
26 Correct 59 ms 5924 KB Output is correct
27 Correct 46 ms 5924 KB Output is correct
28 Correct 73 ms 5924 KB Output is correct
29 Correct 63 ms 5924 KB Output is correct
30 Correct 43 ms 5924 KB Output is correct
31 Correct 0 ms 4300 KB Output is correct
32 Correct 0 ms 4300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4300 KB Output is correct
2 Correct 0 ms 4300 KB Output is correct
3 Correct 0 ms 4300 KB Output is correct
4 Correct 0 ms 4300 KB Output is correct
5 Correct 0 ms 4300 KB Output is correct
6 Correct 0 ms 4300 KB Output is correct
7 Correct 0 ms 4300 KB Output is correct
8 Correct 0 ms 4300 KB Output is correct
9 Correct 0 ms 4300 KB Output is correct
10 Correct 0 ms 4300 KB Output is correct
11 Correct 0 ms 4300 KB Output is correct
12 Correct 0 ms 4300 KB Output is correct
13 Correct 0 ms 4300 KB Output is correct
14 Correct 0 ms 4300 KB Output is correct
15 Correct 0 ms 4444 KB Output is correct
16 Correct 26 ms 4772 KB Output is correct
17 Correct 19 ms 4772 KB Output is correct
18 Correct 19 ms 4772 KB Output is correct
19 Correct 19 ms 4772 KB Output is correct
20 Correct 6 ms 4300 KB Output is correct
21 Correct 86 ms 5924 KB Output is correct
22 Correct 86 ms 5924 KB Output is correct
23 Correct 79 ms 5924 KB Output is correct
24 Correct 73 ms 5924 KB Output is correct
25 Correct 66 ms 7460 KB Output is correct
26 Correct 63 ms 5924 KB Output is correct
27 Correct 96 ms 5924 KB Output is correct
28 Correct 93 ms 5924 KB Output is correct
29 Correct 79 ms 5924 KB Output is correct
30 Correct 36 ms 4772 KB Output is correct
31 Correct 0 ms 4300 KB Output is correct
32 Correct 0 ms 4300 KB Output is correct