답안 #1045096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1045096 2024-08-05T16:43:16 Z DeathIsAwe Gap (APIO16_gap) C++14
30 / 100
30 ms 6396 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long

long long findGap(int test, int n) {
	ll arr[n];
	ll s, t, ans;
	if (test == 1) {
		ans = 0;
		s = 0; t = 1e18;
		for (int i=0;i<n/2;i++) {
			MinMax(s, t, &arr[i], &arr[n - i - 1]);
			s = arr[i] + 1; t = arr[n - i - 1] - 1;
		}
		if (n % 2 == 1) {
			MinMax(s, t, &arr[n/2], &arr[n/2]);
		}
		for (int i=1;i<n;i++) {
			ans = max(ans, arr[i] - arr[i-1]);
		}
		return ans;
	} else {
		ans = 0;
		s = 0; t = 1e18;
		MinMax(s, t, &arr[0], &arr[n-1]);
		if (n == 2) {
			return arr[1] - arr[0];
		}
		vector<ll> chunks(n - 2, (arr[n-1] - arr[0] - 1)/(n - 2));
		for (int i=0;i<(t - s - 1)%(n - 2);i++) {
			chunks[i] ++;
		}
		vector<ll> nums = {arr[0]};
		ll bruh = arr[0] + 1, mn, mx;
		for (int i=0;i<n-2;i++) {
			MinMax(bruh, bruh + chunks[i] - 1, &mn, &mx);
			if (mn == -1) {
				continue;
			}
			nums.push_back(mn); nums.push_back(mx);
			bruh += chunks[i];
		}
		nums.push_back(arr[n-1]);
		for (int i=1;i<nums.size();i++) {
			ans = max(ans, nums[i] - nums[i-1]);
		}
		return ans;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:45:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for (int i=1;i<nums.size();i++) {
      |                ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2488 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 0 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 5 ms 2648 KB Output is correct
17 Correct 7 ms 2780 KB Output is correct
18 Correct 6 ms 2572 KB Output is correct
19 Correct 5 ms 2648 KB Output is correct
20 Correct 4 ms 2648 KB Output is correct
21 Correct 22 ms 3416 KB Output is correct
22 Correct 22 ms 3416 KB Output is correct
23 Correct 22 ms 3416 KB Output is correct
24 Correct 22 ms 3648 KB Output is correct
25 Correct 21 ms 3640 KB Output is correct
26 Correct 22 ms 3416 KB Output is correct
27 Correct 26 ms 3416 KB Output is correct
28 Correct 22 ms 3416 KB Output is correct
29 Correct 29 ms 3416 KB Output is correct
30 Correct 20 ms 3416 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Incorrect 0 ms 2392 KB Output isn't correct
3 Incorrect 0 ms 2392 KB Output isn't correct
4 Incorrect 0 ms 2392 KB Output isn't correct
5 Correct 0 ms 2392 KB Output is correct
6 Incorrect 1 ms 2392 KB Output isn't correct
7 Incorrect 0 ms 2392 KB Output isn't correct
8 Incorrect 0 ms 2392 KB Output isn't correct
9 Incorrect 0 ms 2392 KB Output isn't correct
10 Incorrect 0 ms 2392 KB Output isn't correct
11 Incorrect 1 ms 2392 KB Output isn't correct
12 Incorrect 1 ms 2392 KB Output isn't correct
13 Incorrect 0 ms 2392 KB Output isn't correct
14 Incorrect 0 ms 2392 KB Output isn't correct
15 Correct 1 ms 2392 KB Output is correct
16 Incorrect 5 ms 2904 KB Output isn't correct
17 Incorrect 5 ms 2904 KB Output isn't correct
18 Incorrect 5 ms 2904 KB Output isn't correct
19 Incorrect 5 ms 2904 KB Output isn't correct
20 Incorrect 4 ms 2904 KB Output isn't correct
21 Incorrect 20 ms 4220 KB Output isn't correct
22 Incorrect 20 ms 4184 KB Output isn't correct
23 Incorrect 24 ms 4440 KB Output isn't correct
24 Incorrect 23 ms 4440 KB Output isn't correct
25 Correct 30 ms 6396 KB Output is correct
26 Incorrect 19 ms 4440 KB Output isn't correct
27 Incorrect 21 ms 4184 KB Output isn't correct
28 Incorrect 19 ms 4184 KB Output isn't correct
29 Incorrect 27 ms 4440 KB Output isn't correct
30 Incorrect 19 ms 4440 KB Output isn't correct
31 Incorrect 1 ms 2392 KB Output isn't correct
32 Incorrect 0 ms 2392 KB Output isn't correct