답안 #68484

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68484 2018-08-17T08:10:02 Z KLPP Gap (APIO16_gap) C++14
100 / 100
113 ms 3552 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+1]-numeros[i]);
		}
		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++){
              ~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 3 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 484 KB Output is correct
7 Correct 3 ms 568 KB Output is correct
8 Correct 3 ms 568 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 4 ms 596 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 2 ms 620 KB Output is correct
14 Correct 3 ms 692 KB Output is correct
15 Correct 3 ms 692 KB Output is correct
16 Correct 18 ms 1132 KB Output is correct
17 Correct 19 ms 1132 KB Output is correct
18 Correct 19 ms 1132 KB Output is correct
19 Correct 24 ms 1132 KB Output is correct
20 Correct 13 ms 1132 KB Output is correct
21 Correct 71 ms 2564 KB Output is correct
22 Correct 69 ms 2576 KB Output is correct
23 Correct 70 ms 2576 KB Output is correct
24 Correct 70 ms 2576 KB Output is correct
25 Correct 71 ms 2576 KB Output is correct
26 Correct 70 ms 2576 KB Output is correct
27 Correct 66 ms 2576 KB Output is correct
28 Correct 78 ms 2576 KB Output is correct
29 Correct 68 ms 2576 KB Output is correct
30 Correct 57 ms 2576 KB Output is correct
31 Correct 2 ms 2576 KB Output is correct
32 Correct 3 ms 2576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2576 KB Output is correct
2 Correct 2 ms 2576 KB Output is correct
3 Correct 2 ms 2576 KB Output is correct
4 Correct 2 ms 2576 KB Output is correct
5 Correct 3 ms 2576 KB Output is correct
6 Correct 3 ms 2576 KB Output is correct
7 Correct 2 ms 2576 KB Output is correct
8 Correct 2 ms 2576 KB Output is correct
9 Correct 2 ms 2576 KB Output is correct
10 Correct 3 ms 2576 KB Output is correct
11 Correct 3 ms 2576 KB Output is correct
12 Correct 3 ms 2576 KB Output is correct
13 Correct 4 ms 2576 KB Output is correct
14 Correct 4 ms 2576 KB Output is correct
15 Correct 4 ms 2576 KB Output is correct
16 Correct 29 ms 2576 KB Output is correct
17 Correct 22 ms 2576 KB Output is correct
18 Correct 23 ms 2576 KB Output is correct
19 Correct 23 ms 2576 KB Output is correct
20 Correct 18 ms 2576 KB Output is correct
21 Correct 96 ms 2648 KB Output is correct
22 Correct 107 ms 2648 KB Output is correct
23 Correct 82 ms 2648 KB Output is correct
24 Correct 113 ms 2660 KB Output is correct
25 Correct 82 ms 3552 KB Output is correct
26 Correct 90 ms 3552 KB Output is correct
27 Correct 91 ms 3552 KB Output is correct
28 Correct 83 ms 3552 KB Output is correct
29 Correct 84 ms 3552 KB Output is correct
30 Correct 42 ms 3552 KB Output is correct
31 Correct 2 ms 3552 KB Output is correct
32 Correct 2 ms 3552 KB Output is correct