Submission #102466

# Submission time Handle Problem Language Result Execution time Memory
102466 2019-03-25T07:17:01 Z Nicholas_Patrick Gap (APIO16_gap) C++17
43.3827 / 100
120 ms 5892 KB
#include "gap.h"
#include <set>
using namespace std;

long long findGap(int t, int n){
	set <long long> numbers;
	long long m, M;
	if(t==1){
		m=0;
		M=1000000000000000000;
		while(true){
			if(numbers.size()==n)
				break;
			if(m>M)
				break;
			MinMax(m, M, &m, &M);
			if(m==-1)
				break;
			numbers.insert(m);
			if(m==M)
				break;
			numbers.insert(M);
			m++;M--;
		}
	}else if(t==2){
		long long trueMin, trueMax;
		MinMax(0, 1000000000000000000, &trueMin, &trueMax);
		numbers.insert(trueMin);trueMin++;
		numbers.insert(trueMax);trueMax--;
		for(int i = 0;i < n>>1;i ++){
			m=((long double)((n>>1)-i)*trueMin+(long double)(i)*trueMax)/(n>>1);
			if(i==(n>>1)-1)
				M=1000000000000000000;
			else
				M=((long double)((n>>1)-i-1)*trueMin+(long double)(i+1)*trueMax)/(n>>1);
			while(true){
				if(numbers.size()==n)
					break;
				if(m>M)
					break;
				MinMax(m, M, &m, &M);
				if(m==-1)
					break;
				numbers.insert(m);
				if(m==M)
					break;
				numbers.insert(M);
				m++;M--;
			}
		}
	}
	m=0;
	set <long long>::iterator it=numbers.begin();
	M=*it;
	while(++it!=numbers.end()){
		m=max(m, *it-M);
		M=*it;
	}
	return m;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:12:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(numbers.size()==n)
       ~~~~~~~~~~~~~~^~~
gap.cpp:37:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(numbers.size()==n)
        ~~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 4 ms 428 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 22 ms 1664 KB Output is correct
17 Correct 21 ms 1664 KB Output is correct
18 Correct 25 ms 1664 KB Output is correct
19 Correct 24 ms 1784 KB Output is correct
20 Correct 16 ms 1664 KB Output is correct
21 Correct 97 ms 5752 KB Output is correct
22 Correct 96 ms 5892 KB Output is correct
23 Correct 100 ms 5844 KB Output is correct
24 Correct 82 ms 5788 KB Output is correct
25 Correct 77 ms 5752 KB Output is correct
26 Correct 94 ms 5880 KB Output is correct
27 Correct 83 ms 5780 KB Output is correct
28 Correct 85 ms 5828 KB Output is correct
29 Correct 98 ms 5880 KB Output is correct
30 Correct 77 ms 5748 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Partially correct 2 ms 256 KB Partially correct
4 Correct 2 ms 256 KB Output is correct
5 Partially correct 2 ms 256 KB Partially correct
6 Partially correct 3 ms 384 KB Partially correct
7 Partially correct 2 ms 256 KB Partially correct
8 Partially correct 2 ms 256 KB Partially correct
9 Partially correct 3 ms 384 KB Partially correct
10 Partially correct 2 ms 256 KB Partially correct
11 Partially correct 3 ms 384 KB Partially correct
12 Partially correct 3 ms 384 KB Partially correct
13 Partially correct 3 ms 384 KB Partially correct
14 Partially correct 2 ms 384 KB Partially correct
15 Correct 4 ms 384 KB Output is correct
16 Partially correct 23 ms 1656 KB Partially correct
17 Partially correct 25 ms 1752 KB Partially correct
18 Partially correct 29 ms 1656 KB Partially correct
19 Partially correct 23 ms 1664 KB Partially correct
20 Partially correct 21 ms 1656 KB Partially correct
21 Partially correct 89 ms 5748 KB Partially correct
22 Partially correct 90 ms 5752 KB Partially correct
23 Partially correct 95 ms 5832 KB Partially correct
24 Partially correct 120 ms 5752 KB Partially correct
25 Correct 96 ms 5752 KB Output is correct
26 Partially correct 102 ms 5880 KB Partially correct
27 Partially correct 93 ms 5732 KB Partially correct
28 Partially correct 113 ms 5724 KB Partially correct
29 Partially correct 103 ms 5772 KB Partially correct
30 Partially correct 81 ms 5812 KB Partially correct
31 Partially correct 3 ms 432 KB Partially correct
32 Partially correct 2 ms 384 KB Partially correct