답안 #1012049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012049 2024-07-01T15:06:25 Z zsombor Gap (APIO16_gap) C++17
89.0376 / 100
41 ms 4392 KB
#include "gap.h"
#include <vector>
using namespace std;
using ll = long long;

const ll m = 1000000000000000000;

ll solve1(ll n) {
	ll l = 0, r = m, mn, mx, ans = 0;
	vector <ll> v;
	vector <ll> v2;
	while (v.size() + v2.size() < n) {
		MinMax(l, r, &mn, &mx);
		l = mn + 1;
		r = mx - 1;
		v.push_back(mn);
		v2.push_back(mx);
	}
	while (v2.size()) { v.push_back(v2.back()); v2.pop_back(); }
	for (int i = 1; i < v.size(); i++) ans = max(ans, v[i] - v[i - 1]);
	return ans;
}

ll solve2(ll n) {
	ll a1, an, mn, mx, ans = 0;
	MinMax(0, m, &a1, &an);
	ll d = a1, u = a1, l = (an - a1) / (n - 1);
	vector <ll> v;
	while (d < an - 1) {
		MinMax(d + 1, min(d + l, an - 1), &mn, &mx);
		d += l;
		if (mn == -1) continue;
		ans = max(ans, mn - u);
		u = mx;
	}
	ans = max(ans, an - u);
	return ans;
}

ll findGap(int T, int N) {
	return (T == 1 ? solve1(N) : solve2(N));
}

Compilation message

gap.cpp: In function 'll solve1(ll)':
gap.cpp:12:30: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   12 |  while (v.size() + v2.size() < n) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~
gap.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (int i = 1; i < v.size(); i++) ans = max(ans, v[i] - v[i - 1]);
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 0 ms 2392 KB Output is correct
16 Correct 6 ms 2904 KB Output is correct
17 Correct 7 ms 3012 KB Output is correct
18 Correct 6 ms 2904 KB Output is correct
19 Correct 6 ms 3044 KB Output is correct
20 Correct 5 ms 2904 KB Output is correct
21 Correct 29 ms 4236 KB Output is correct
22 Correct 25 ms 4220 KB Output is correct
23 Correct 33 ms 4216 KB Output is correct
24 Correct 26 ms 4392 KB Output is correct
25 Correct 20 ms 4188 KB Output is correct
26 Correct 23 ms 4220 KB Output is correct
27 Correct 22 ms 4212 KB Output is correct
28 Correct 21 ms 4220 KB Output is correct
29 Correct 26 ms 4232 KB Output is correct
30 Correct 22 ms 4220 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2472 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 0 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 9 ms 2576 KB Output is correct
17 Correct 9 ms 2392 KB Output is correct
18 Correct 10 ms 2676 KB Output is correct
19 Correct 9 ms 2392 KB Output is correct
20 Partially correct 4 ms 2392 KB Partially correct
21 Correct 30 ms 2852 KB Output is correct
22 Correct 34 ms 2648 KB Output is correct
23 Correct 30 ms 2644 KB Output is correct
24 Correct 32 ms 2648 KB Output is correct
25 Correct 29 ms 2648 KB Output is correct
26 Correct 41 ms 2648 KB Output is correct
27 Correct 30 ms 2648 KB Output is correct
28 Correct 37 ms 2648 KB Output is correct
29 Correct 31 ms 2648 KB Output is correct
30 Partially correct 22 ms 2648 KB Partially correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct