Submission #25847

# Submission time Handle Problem Language Result Execution time Memory
25847 2017-06-24T11:48:51 Z gs14004 Gap (APIO16_gap) C++11
100 / 100
113 ms 7460 KB
#include "gap.h"
#include <vector>
#include <algorithm>
using namespace std;
typedef long long lint;
typedef pair<lint, lint> pi;

pi query(lint s, lint e){
	pi ret;
	MinMax(s, e, &ret.first, &ret.second);
	return ret;
}

long long findGap(int T, int N)
{
	vector<lint> a;
	lint ret = 0;
	if(T == 1){
		lint s = 0, e = 2e18;
		while(N >= 1){
			auto t = query(s, e);
			a.push_back(t.first);
			a.push_back(t.second);
			s = t.first + 1, e = t.second - 1;
			N -= 2;
		}
	}
	else{
		pi q = query(0, 2e18);
		lint triv = (q.second - q.first + N - 2) / (N - 1);
		ret = triv;
		for(lint p = q.first; p <= q.second; p += triv + 1){
			auto t = query(p, p + triv);
			a.push_back(t.first);
			a.push_back(t.second);
		}
	}
	sort(a.begin(), a.end());
	for(int i=0; i<a.size()-1; i++){
		ret = max(ret, a[i+1] - a[i]);
	}
	return ret;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<a.size()-1; i++){
                ^
# 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 13 ms 4772 KB Output is correct
17 Correct 13 ms 4772 KB Output is correct
18 Correct 13 ms 4772 KB Output is correct
19 Correct 19 ms 4772 KB Output is correct
20 Correct 9 ms 4772 KB Output is correct
21 Correct 63 ms 5924 KB Output is correct
22 Correct 59 ms 5924 KB Output is correct
23 Correct 63 ms 5924 KB Output is correct
24 Correct 76 ms 5924 KB Output is correct
25 Correct 53 ms 5924 KB Output is correct
26 Correct 59 ms 5924 KB Output is correct
27 Correct 66 ms 5924 KB Output is correct
28 Correct 66 ms 5924 KB Output is correct
29 Correct 73 ms 5924 KB Output is correct
30 Correct 46 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 4444 KB Output is correct
12 Correct 0 ms 4444 KB Output is correct
13 Correct 0 ms 4444 KB Output is correct
14 Correct 0 ms 4444 KB Output is correct
15 Correct 0 ms 4444 KB Output is correct
16 Correct 19 ms 5156 KB Output is correct
17 Correct 19 ms 5156 KB Output is correct
18 Correct 19 ms 5156 KB Output is correct
19 Correct 19 ms 5156 KB Output is correct
20 Correct 9 ms 5156 KB Output is correct
21 Correct 93 ms 7460 KB Output is correct
22 Correct 79 ms 7460 KB Output is correct
23 Correct 113 ms 7460 KB Output is correct
24 Correct 93 ms 7460 KB Output is correct
25 Correct 76 ms 7460 KB Output is correct
26 Correct 103 ms 7460 KB Output is correct
27 Correct 89 ms 7460 KB Output is correct
28 Correct 86 ms 7460 KB Output is correct
29 Correct 89 ms 7460 KB Output is correct
30 Correct 36 ms 7460 KB Output is correct
31 Correct 0 ms 4300 KB Output is correct
32 Correct 0 ms 4300 KB Output is correct