Submission #1045104

# Submission time Handle Problem Language Result Execution time Memory
1045104 2024-08-05T16:50:05 Z DeathIsAwe Gap (APIO16_gap) C++14
30 / 100
32 ms 6556 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 (ll i=0;i<(arr[n-1] - arr[0] - 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 (ll 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:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for (ll i=1;i<nums.size();i++) {
      |               ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 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 0 ms 2392 KB Output is correct
14 Correct 0 ms 2392 KB Output is correct
15 Correct 0 ms 2392 KB Output is correct
16 Correct 5 ms 2784 KB Output is correct
17 Correct 6 ms 2648 KB Output is correct
18 Correct 6 ms 2648 KB Output is correct
19 Correct 6 ms 2740 KB Output is correct
20 Correct 5 ms 2648 KB Output is correct
21 Correct 22 ms 3532 KB Output is correct
22 Correct 24 ms 3416 KB Output is correct
23 Correct 23 ms 3416 KB Output is correct
24 Correct 22 ms 3416 KB Output is correct
25 Correct 23 ms 3416 KB Output is correct
26 Correct 24 ms 3640 KB Output is correct
27 Correct 22 ms 3416 KB Output is correct
28 Correct 22 ms 3416 KB Output is correct
29 Correct 23 ms 3416 KB Output is correct
30 Correct 18 ms 3416 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 2392 KB Output isn't correct
3 Incorrect 1 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 6 ms 2900 KB Output isn't correct
20 Incorrect 4 ms 2904 KB Output isn't correct
21 Incorrect 20 ms 4440 KB Output isn't correct
22 Incorrect 20 ms 4184 KB Output isn't correct
23 Incorrect 27 ms 4184 KB Output isn't correct
24 Incorrect 20 ms 4252 KB Output isn't correct
25 Correct 32 ms 6556 KB Output is correct
26 Incorrect 19 ms 4440 KB Output isn't correct
27 Incorrect 29 ms 4184 KB Output isn't correct
28 Incorrect 20 ms 4440 KB Output isn't correct
29 Incorrect 21 ms 4440 KB Output isn't correct
30 Incorrect 18 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