Submission #68462

# Submission time Handle Problem Language Result Execution time Memory
68462 2018-08-17T07:31:58 Z KLPP Gap (APIO16_gap) C++14
70 / 100
100 ms 3608 KB
#include "gap.h"
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long lld;
long long maximo(lld a, lld b){
if(a<b)return b;
return a;
}
long long minimo(lld a, lld b){
if(a<b)return a;
return b;
}
long long findGap(int T, int N)
{
	if(T==1){
		vector<lld> numeros;
		lld a,b;
		a=0;
		b=1000000000000000000;
		while(a!=-1 && numeros.size()<N){//cout<<a<<" "<<b<<endl;
			lld A,B;
			MinMax(a,b,&A,&B);
			a=A;
			b=B;
			if(a!=-1){
				numeros.push_back(a);
				numeros.push_back(b);
				a++;b--;
			}
		}
		sort(numeros.begin(),numeros.end());
		lld max=0;
		for(int i=0;i<numeros.size()-1;i++){
			max=maximo(max,numeros[i]-numeros[i-1]);
		}
		return max;
	}
	lld min,max;
	MinMax(0,1000000000000000000,&min,&max);
	lld Maxlength=(max-min-1)/N;
	Maxlength++;
	vector<lld> candidates;
	candidates.push_back(min);
	for(lld i=min+1;i<max;i+=Maxlength){
		lld s=i;
		lld t=minimo(i+Maxlength-1,max);
		lld c1,c2;
		MinMax(s,t,&c1,&c2);
		if(c1!=-1){
			candidates.push_back(c1);
			candidates.push_back(c2);
		}
	}candidates.push_back(max);
	for(int i=0;i<candidates.size()-1;i++){
		Maxlength=maximo(Maxlength,candidates[i+1]-candidates[i]);
	}
	return Maxlength;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:22:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(a!=-1 && numeros.size()<N){//cout<<a<<" "<<b<<endl;
                  ~~~~~~~~~~~~~~^~
gap.cpp:35:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<numeros.size()-1;i++){
               ~^~~~~~~~~~~~~~~~~
gap.cpp:56:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<candidates.size()-1;i++){
              ~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Correct 3 ms 480 KB Output is correct
3 Correct 3 ms 480 KB Output is correct
4 Incorrect 2 ms 480 KB Output isn't correct
5 Incorrect 3 ms 480 KB Output isn't correct
6 Correct 2 ms 480 KB Output is correct
7 Correct 3 ms 480 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 3 ms 700 KB Output is correct
11 Correct 3 ms 700 KB Output is correct
12 Correct 4 ms 700 KB Output is correct
13 Correct 3 ms 700 KB Output is correct
14 Correct 4 ms 700 KB Output is correct
15 Incorrect 4 ms 700 KB Output isn't correct
16 Correct 20 ms 1180 KB Output is correct
17 Correct 21 ms 1180 KB Output is correct
18 Correct 23 ms 1180 KB Output is correct
19 Correct 21 ms 1232 KB Output is correct
20 Correct 15 ms 1232 KB Output is correct
21 Correct 80 ms 2544 KB Output is correct
22 Correct 70 ms 2564 KB Output is correct
23 Correct 89 ms 2564 KB Output is correct
24 Correct 76 ms 2564 KB Output is correct
25 Incorrect 68 ms 2672 KB Output isn't correct
26 Correct 70 ms 2672 KB Output is correct
27 Correct 75 ms 2672 KB Output is correct
28 Correct 68 ms 2672 KB Output is correct
29 Correct 85 ms 2676 KB Output is correct
30 Correct 56 ms 2676 KB Output is correct
31 Incorrect 3 ms 2676 KB Output isn't correct
32 Correct 3 ms 2676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2676 KB Output is correct
2 Correct 2 ms 2676 KB Output is correct
3 Correct 3 ms 2676 KB Output is correct
4 Correct 2 ms 2676 KB Output is correct
5 Correct 3 ms 2676 KB Output is correct
6 Correct 2 ms 2676 KB Output is correct
7 Correct 2 ms 2676 KB Output is correct
8 Correct 3 ms 2676 KB Output is correct
9 Correct 3 ms 2676 KB Output is correct
10 Correct 2 ms 2676 KB Output is correct
11 Correct 4 ms 2676 KB Output is correct
12 Correct 3 ms 2676 KB Output is correct
13 Correct 4 ms 2676 KB Output is correct
14 Correct 4 ms 2676 KB Output is correct
15 Correct 3 ms 2676 KB Output is correct
16 Correct 22 ms 2676 KB Output is correct
17 Correct 24 ms 2676 KB Output is correct
18 Correct 22 ms 2676 KB Output is correct
19 Correct 22 ms 2676 KB Output is correct
20 Correct 15 ms 2676 KB Output is correct
21 Correct 85 ms 2676 KB Output is correct
22 Correct 86 ms 2676 KB Output is correct
23 Correct 89 ms 2676 KB Output is correct
24 Correct 83 ms 2676 KB Output is correct
25 Correct 100 ms 3608 KB Output is correct
26 Correct 84 ms 3608 KB Output is correct
27 Correct 87 ms 3608 KB Output is correct
28 Correct 91 ms 3608 KB Output is correct
29 Correct 85 ms 3608 KB Output is correct
30 Correct 45 ms 3608 KB Output is correct
31 Correct 3 ms 3608 KB Output is correct
32 Correct 2 ms 3608 KB Output is correct