답안 #42104

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42104 2018-02-22T14:23:09 Z IvanC Gap (APIO16_gap) C++14
100 / 100
93 ms 41420 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
mt19937_64 gen(rand() ^ (rand() << 16));
typedef long long ll;
typedef pair<ll,ll> ii;
ll NN,TT,maior;
ll findGap(int T,int N){
	TT = T;
	NN = N;
	ll ini = 0,fim = (ll)1e18;
	if(T == 1){
		vector<ll> vetor;
		for(ll qtd = N;qtd >= 1;qtd -= 2){
			ll copia1,copia2;
			MinMax(ini,fim,&copia1,&copia2);
			vetor.push_back(copia1);
			vetor.push_back(copia2);
			ini = copia1;
			fim = copia2;
			ini++,fim--;
		}
		sort(vetor.begin(),vetor.end());
		for(ll i = 0;i+1<vetor.size();i++) maior = max(maior, vetor[i+1] - vetor[i] );
		return maior;
	}
	vector<ll> vetor;
	ll lo,hi;
	MinMax(ini,fim,&lo,&hi);
	ini = lo;
	fim = hi;
	ll gap = (ll)ceil(hi - lo)/double(N-1);
	for(ll left = ini;left<=fim;left += gap + 1){
		ll right = left + gap;
		MinMax(left,right,&lo,&hi);
		vetor.push_back(lo);
		vetor.push_back(hi);
	}
	sort(vetor.begin(),vetor.end());
	for(ll i = 1;i<vetor.size();i++) maior = max(maior, vetor[i] - vetor[i-1] );
	return maior;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:24:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ll i = 0;i+1<vetor.size();i++) maior = max(maior, vetor[i+1] - vetor[i] );
                   ^
gap.cpp:40:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ll i = 1;i<vetor.size();i++) maior = max(maior, vetor[i] - vetor[i-1] );
                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 524 KB Output is correct
6 Correct 2 ms 616 KB Output is correct
7 Correct 2 ms 748 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
9 Correct 2 ms 748 KB Output is correct
10 Correct 2 ms 752 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 2 ms 860 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 3 ms 876 KB Output is correct
15 Correct 2 ms 940 KB Output is correct
16 Correct 21 ms 1960 KB Output is correct
17 Correct 16 ms 2424 KB Output is correct
18 Correct 17 ms 2888 KB Output is correct
19 Correct 16 ms 3480 KB Output is correct
20 Correct 12 ms 3480 KB Output is correct
21 Correct 62 ms 6784 KB Output is correct
22 Correct 60 ms 8624 KB Output is correct
23 Correct 64 ms 10344 KB Output is correct
24 Correct 63 ms 12312 KB Output is correct
25 Correct 59 ms 13548 KB Output is correct
26 Correct 65 ms 15404 KB Output is correct
27 Correct 62 ms 17120 KB Output is correct
28 Correct 62 ms 18964 KB Output is correct
29 Correct 59 ms 20932 KB Output is correct
30 Correct 47 ms 21492 KB Output is correct
31 Correct 2 ms 21492 KB Output is correct
32 Correct 2 ms 21492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 21492 KB Output is correct
2 Correct 2 ms 21492 KB Output is correct
3 Correct 2 ms 21492 KB Output is correct
4 Correct 2 ms 21492 KB Output is correct
5 Correct 2 ms 21492 KB Output is correct
6 Correct 2 ms 21492 KB Output is correct
7 Correct 2 ms 21492 KB Output is correct
8 Correct 2 ms 21492 KB Output is correct
9 Correct 2 ms 21492 KB Output is correct
10 Correct 2 ms 21492 KB Output is correct
11 Correct 3 ms 21492 KB Output is correct
12 Correct 3 ms 21492 KB Output is correct
13 Correct 3 ms 21492 KB Output is correct
14 Correct 3 ms 21492 KB Output is correct
15 Correct 3 ms 21492 KB Output is correct
16 Correct 23 ms 21492 KB Output is correct
17 Correct 22 ms 21564 KB Output is correct
18 Correct 25 ms 22028 KB Output is correct
19 Correct 24 ms 22492 KB Output is correct
20 Correct 11 ms 22700 KB Output is correct
21 Correct 87 ms 26688 KB Output is correct
22 Correct 93 ms 28532 KB Output is correct
23 Correct 92 ms 30384 KB Output is correct
24 Correct 86 ms 32120 KB Output is correct
25 Correct 78 ms 33456 KB Output is correct
26 Correct 92 ms 35200 KB Output is correct
27 Correct 86 ms 37044 KB Output is correct
28 Correct 91 ms 38888 KB Output is correct
29 Correct 86 ms 40732 KB Output is correct
30 Correct 48 ms 41420 KB Output is correct
31 Correct 2 ms 41420 KB Output is correct
32 Correct 2 ms 41420 KB Output is correct