답안 #23453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
23453 2017-05-09T16:52:26 Z ztrong Gap (APIO16_gap) C++14
56.3068 / 100
93 ms 5144 KB
#include <bits/stdc++.h>
#include "gap.h"

using namespace std;

#define FOR(i, a, b) for (int i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for (int i = a, _b = b; i >= _b; --i)
#define REP(i, a) for (int i = 0, _a = a; i < _a; ++i)
#define llint long long
#define sz(x) (x.size())
#define LL(x) (x * 2)
#define RR(x) (x * 2 + 1)
#define fi first
#define se second
#define db(x) cout << #x << " = " << x << endl;
#define BIT(x, i) ((x >> i) & 1)
#define MASK(i) (1ll << i)
#define times clock() * 1.0 / CLOCKS_PER_SEC

void openFile() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef Tr___
	freopen("test.inp", "r", stdin);
	freopen("test.out", "w", stdout);
	#endif
}

const int maxN = 1e5 + 5;
const int maxM = 1e6 + 5;
const llint INF = 1e18 + 1;

llint findGap(int T, int N) {
	if (T == 1) {
		llint l = -1, r = INF;
		llint nl, nr;
		llint res = 0;
		FOR(i, 1, (N + 1) / 2) {
			MinMax(l + 1, r - 1, &nl, &nr);
			if (l != -1) {
				res = max(res, max(nl - l, r - nr));
			}
			else if (N == 2) {
				res = nr - nl;
				break;
			}
			l = nl; r = nr;
		}
		if (N % 2 == 0) res = max(res, nr - nl);
		return res;
	}
	else {
		llint l, r;
		MinMax(-1, INF, &l, &r);
		if (N == 2) {
			return r - l;
		}
		llint lower = (r - l) / (N - 1);
		llint res = lower;
		llint nl, nr;
		do {
			llint x = 0;
			nl = nr = -1;
			while (nl == -1) {
				++x;
				MinMax(l + 1, l + lower * x, &nl, &nr);
			}

			res = max(res, nl - l);
			l = nr;
		} while (l != r);
		return res;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5144 KB Output is correct
2 Correct 0 ms 5144 KB Output is correct
3 Correct 0 ms 5144 KB Output is correct
4 Correct 0 ms 5144 KB Output is correct
5 Correct 0 ms 5144 KB Output is correct
6 Correct 0 ms 5144 KB Output is correct
7 Correct 0 ms 5144 KB Output is correct
8 Correct 0 ms 5144 KB Output is correct
9 Correct 0 ms 5144 KB Output is correct
10 Correct 0 ms 5144 KB Output is correct
11 Correct 0 ms 5144 KB Output is correct
12 Correct 0 ms 5144 KB Output is correct
13 Correct 0 ms 5144 KB Output is correct
14 Correct 0 ms 5144 KB Output is correct
15 Correct 0 ms 5144 KB Output is correct
16 Correct 13 ms 5144 KB Output is correct
17 Correct 13 ms 5144 KB Output is correct
18 Correct 13 ms 5144 KB Output is correct
19 Correct 16 ms 5144 KB Output is correct
20 Correct 9 ms 5144 KB Output is correct
21 Correct 66 ms 5144 KB Output is correct
22 Correct 63 ms 5144 KB Output is correct
23 Correct 53 ms 5144 KB Output is correct
24 Correct 53 ms 5144 KB Output is correct
25 Correct 46 ms 5144 KB Output is correct
26 Correct 69 ms 5144 KB Output is correct
27 Correct 59 ms 5144 KB Output is correct
28 Correct 56 ms 5144 KB Output is correct
29 Correct 36 ms 5144 KB Output is correct
30 Correct 36 ms 5144 KB Output is correct
31 Incorrect 0 ms 5144 KB Output isn't correct
32 Correct 0 ms 5144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5144 KB Output is correct
2 Partially correct 0 ms 5144 KB Partially correct
3 Partially correct 0 ms 5144 KB Partially correct
4 Partially correct 0 ms 5144 KB Partially correct
5 Correct 0 ms 5144 KB Output is correct
6 Partially correct 0 ms 5144 KB Partially correct
7 Partially correct 0 ms 5144 KB Partially correct
8 Partially correct 0 ms 5144 KB Partially correct
9 Partially correct 0 ms 5144 KB Partially correct
10 Partially correct 0 ms 5144 KB Partially correct
11 Partially correct 0 ms 5144 KB Partially correct
12 Partially correct 0 ms 5144 KB Partially correct
13 Partially correct 0 ms 5144 KB Partially correct
14 Partially correct 0 ms 5144 KB Partially correct
15 Correct 0 ms 5144 KB Output is correct
16 Partially correct 23 ms 5144 KB Partially correct
17 Partially correct 13 ms 5144 KB Partially correct
18 Partially correct 23 ms 5144 KB Partially correct
19 Partially correct 19 ms 5144 KB Partially correct
20 Partially correct 6 ms 5144 KB Partially correct
21 Partially correct 76 ms 5144 KB Partially correct
22 Partially correct 89 ms 5144 KB Partially correct
23 Partially correct 89 ms 5144 KB Partially correct
24 Partially correct 76 ms 5144 KB Partially correct
25 Correct 69 ms 5144 KB Output is correct
26 Partially correct 86 ms 5144 KB Partially correct
27 Partially correct 93 ms 5144 KB Partially correct
28 Partially correct 83 ms 5144 KB Partially correct
29 Partially correct 93 ms 5144 KB Partially correct
30 Partially correct 39 ms 5144 KB Partially correct
31 Partially correct 0 ms 5144 KB Partially correct
32 Partially correct 0 ms 5144 KB Partially correct