답안 #443027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
443027 2021-07-09T13:41:39 Z hibye1217 Gap (APIO16_gap) C++17
100 / 100
64 ms 3228 KB
#ifndef NOTSUBMIT
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#endif

ll arr[100020];

ll findGap(int T, int N){
	if (T == 1){
		ll mn = 0, mx = 1e18;
		int st = 1, ed = N;
		while (st <= ed){
			MinMax(mn, mx, &arr[st], &arr[ed]);
			mn = arr[st]+1; mx = arr[ed]-1;
			st += 1; ed -= 1;
		}
		ll ans = 0;
		for (int i = 1; i < N; i++){
			ans = max(ans, arr[i+1] - arr[i]);
		}
		return ans;
	}
	if (T == 2){
		ll mn = 0, mx = 1e18;
		MinMax(0, 1e18, &mn, &mx);
		vector<ll> v;
		ll gap = (mx-mn + N-2) / (N-1);
		for (int i = 1; i < N; i++){
			ll st = mn + (i-1)*gap;
			ll ed = st+gap - 1;
			ll mnv=0, mxv=0;
			MinMax(st, ed, &mnv, &mxv);
			if (mnv != -1){ v.push_back(mnv); }
			if (mxv != -1){ v.push_back(mxv); }
		}
		v.push_back(mx);
		int vl = v.size();
		ll ans = 0;
		for (int i = 1; i < vl; i++){
			ans = max(ans, v[i] - v[i-1]);
		}
		return ans;
	}
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 11 ms 700 KB Output is correct
17 Correct 12 ms 584 KB Output is correct
18 Correct 11 ms 712 KB Output is correct
19 Correct 11 ms 584 KB Output is correct
20 Correct 8 ms 584 KB Output is correct
21 Correct 43 ms 1760 KB Output is correct
22 Correct 49 ms 1904 KB Output is correct
23 Correct 43 ms 1836 KB Output is correct
24 Correct 45 ms 1744 KB Output is correct
25 Correct 42 ms 1856 KB Output is correct
26 Correct 43 ms 1824 KB Output is correct
27 Correct 43 ms 1860 KB Output is correct
28 Correct 44 ms 1776 KB Output is correct
29 Correct 44 ms 1824 KB Output is correct
30 Correct 34 ms 1852 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 15 ms 908 KB Output is correct
17 Correct 16 ms 892 KB Output is correct
18 Correct 16 ms 1016 KB Output is correct
19 Correct 15 ms 860 KB Output is correct
20 Correct 7 ms 420 KB Output is correct
21 Correct 62 ms 2184 KB Output is correct
22 Correct 63 ms 2200 KB Output is correct
23 Correct 61 ms 2204 KB Output is correct
24 Correct 64 ms 2344 KB Output is correct
25 Correct 57 ms 3228 KB Output is correct
26 Correct 63 ms 2232 KB Output is correct
27 Correct 60 ms 2148 KB Output is correct
28 Correct 61 ms 2208 KB Output is correct
29 Correct 62 ms 2232 KB Output is correct
30 Correct 32 ms 1472 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct