답안 #1012045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012045 2024-07-01T15:03:46 Z zsombor Gap (APIO16_gap) C++17
30 / 100
52 ms 4336 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) {
		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 1 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 344 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 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 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 2388 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 6 ms 1112 KB Output is correct
17 Correct 6 ms 1112 KB Output is correct
18 Correct 8 ms 1112 KB Output is correct
19 Correct 7 ms 1112 KB Output is correct
20 Correct 6 ms 2996 KB Output is correct
21 Correct 26 ms 4336 KB Output is correct
22 Correct 25 ms 4216 KB Output is correct
23 Correct 25 ms 2684 KB Output is correct
24 Correct 33 ms 2592 KB Output is correct
25 Correct 24 ms 2684 KB Output is correct
26 Correct 37 ms 4208 KB Output is correct
27 Correct 23 ms 2676 KB Output is correct
28 Correct 38 ms 2740 KB Output is correct
29 Correct 29 ms 4292 KB Output is correct
30 Correct 28 ms 2680 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 0 ms 344 KB Execution failed because the return code was nonzero
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 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 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 8 ms 600 KB Output is correct
17 Correct 11 ms 640 KB Output is correct
18 Correct 8 ms 2392 KB Output is correct
19 Correct 8 ms 600 KB Output is correct
20 Partially correct 5 ms 596 KB Partially correct
21 Correct 31 ms 2876 KB Output is correct
22 Correct 48 ms 1112 KB Output is correct
23 Correct 34 ms 1060 KB Output is correct
24 Correct 32 ms 1112 KB Output is correct
25 Correct 43 ms 2784 KB Output is correct
26 Correct 52 ms 1116 KB Output is correct
27 Correct 33 ms 2648 KB Output is correct
28 Correct 38 ms 2648 KB Output is correct
29 Correct 36 ms 1100 KB Output is correct
30 Partially correct 24 ms 2828 KB Partially correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct