Submission #1045110

# Submission time Handle Problem Language Result Execution time Memory
1045110 2024-08-05T16:58:26 Z DeathIsAwe Gap (APIO16_gap) C++14
100 / 100
39 ms 6604 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 == (ll)-1) {
				bruh += chunks[i];
				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:46: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]
   46 |   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 0 ms 2392 KB Output is correct
7 Correct 1 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 0 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 5 ms 2784 KB Output is correct
17 Correct 6 ms 2648 KB Output is correct
18 Correct 5 ms 2648 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 3504 KB Output is correct
22 Correct 28 ms 3416 KB Output is correct
23 Correct 21 ms 3416 KB Output is correct
24 Correct 23 ms 3416 KB Output is correct
25 Correct 18 ms 3416 KB Output is correct
26 Correct 25 ms 3560 KB Output is correct
27 Correct 21 ms 3416 KB Output is correct
28 Correct 25 ms 3416 KB Output is correct
29 Correct 24 ms 3416 KB Output is correct
30 Correct 17 ms 3416 KB Output is correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2644 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 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 3284 KB Output is correct
17 Correct 8 ms 3284 KB Output is correct
18 Correct 11 ms 3288 KB Output is correct
19 Correct 8 ms 3284 KB Output is correct
20 Correct 5 ms 2804 KB Output is correct
21 Correct 37 ms 5528 KB Output is correct
22 Correct 29 ms 5584 KB Output is correct
23 Correct 31 ms 5576 KB Output is correct
24 Correct 30 ms 5532 KB Output is correct
25 Correct 29 ms 6604 KB Output is correct
26 Correct 39 ms 5576 KB Output is correct
27 Correct 30 ms 5584 KB Output is correct
28 Correct 31 ms 5584 KB Output is correct
29 Correct 32 ms 5584 KB Output is correct
30 Correct 18 ms 4696 KB Output is correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct