답안 #246009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246009 2020-07-08T02:29:54 Z wwdd Gap (APIO16_gap) C++14
100 / 100
76 ms 3364 KB
#include <stdio.h>
#include <stdlib.h>
#include "gap.h"

#include <vector>
using ll = long long;
using vl = std::vector<ll>;
using namespace std;
ll lol(ll n) {
	vl wa,wb;
	ll lo = 0,hi = 1e18;
	ll ok = (n+1)/2;
	for(int i=0;i<ok;i++) {
		ll ma,mi;
		MinMax(lo,hi,&mi,&ma);
		lo = mi+1;hi = ma-1;
		wa.push_back(mi);
		wb.push_back(ma);
	}
	if(n&1) {wa.pop_back();}
	for(int i=wb.size()-1;i>=0;i--) {wa.push_back(wb[i]);}
	ll res = 0;
	for(int i=1;i<n;i++) {
		res = max(res,wa[i]-wa[i-1]);
	}
	return res;
}
ll solve(ll n) {
	ll lo = 0,hi = 1e18;
	ll st,ed;
	MinMax(lo,hi,&st,&ed);
	ll bd = (ed-st+n-2)/(n-1);
	vl w;
	w.push_back(st);
	lo = st+1;
	for(int i=0;i<n-1;i++) {
		if(lo > ed) {break;}
		hi = min(lo+bd,ed);
		ll sa,sb;
		MinMax(lo,hi,&sa,&sb);
		if(sa != -1) {
			w.push_back(sa);
			w.push_back(sb);
		}
		lo = hi+1;
	}
	w.push_back(ed);
	ll res = 0;
	for(int i=1;i<w.size();i++) {
		res = max(res,w[i]-w[i-1]);
	}
	return res;
}
long long findGap(int T, int N) {
	if(T == 1) {
		return lol(N);
	} else {
		return solve(N);
	}
}

Compilation message

gap.cpp: In function 'll solve(ll)':
gap.cpp:49:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1;i<w.size();i++) {
              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 19 ms 1000 KB Output is correct
17 Correct 17 ms 1024 KB Output is correct
18 Correct 16 ms 1024 KB Output is correct
19 Correct 19 ms 1024 KB Output is correct
20 Correct 13 ms 1024 KB Output is correct
21 Correct 54 ms 2692 KB Output is correct
22 Correct 55 ms 2588 KB Output is correct
23 Correct 58 ms 2716 KB Output is correct
24 Correct 57 ms 2716 KB Output is correct
25 Correct 54 ms 2692 KB Output is correct
26 Correct 56 ms 2716 KB Output is correct
27 Correct 53 ms 2588 KB Output is correct
28 Correct 58 ms 2716 KB Output is correct
29 Correct 56 ms 2652 KB Output is correct
30 Correct 39 ms 2716 KB Output is correct
31 Correct 4 ms 256 KB Output is correct
32 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 20 ms 896 KB Output is correct
17 Correct 21 ms 896 KB Output is correct
18 Correct 20 ms 896 KB Output is correct
19 Correct 19 ms 896 KB Output is correct
20 Correct 11 ms 512 KB Output is correct
21 Correct 70 ms 2288 KB Output is correct
22 Correct 70 ms 2288 KB Output is correct
23 Correct 69 ms 2288 KB Output is correct
24 Correct 76 ms 2388 KB Output is correct
25 Correct 62 ms 3364 KB Output is correct
26 Correct 69 ms 2292 KB Output is correct
27 Correct 68 ms 2244 KB Output is correct
28 Correct 70 ms 2288 KB Output is correct
29 Correct 69 ms 2288 KB Output is correct
30 Correct 35 ms 1528 KB Output is correct
31 Correct 4 ms 256 KB Output is correct
32 Correct 4 ms 384 KB Output is correct