Submission #992087

# Submission time Handle Problem Language Result Execution time Memory
992087 2024-06-03T21:15:15 Z MladenP Gap (APIO16_gap) C++17
30 / 100
46 ms 2840 KB
#include "gap.h"
#include <algorithm>
#include <iostream> 

using namespace std;

const long long MIN = 0;
const long long MAX = 1'000'000'000'000'000'000;
long long findGap(int T, int N)
{
	if (T == 1) {
		long long mn, mx; 
		long long prev_mn, prev_mx;
		long long sol = 0;
		MinMax(MIN, MAX, &prev_mn, &prev_mx);
		for (int i = 3; i <= N; i+=2) {
			MinMax(prev_mn+1, prev_mx-1, &mn, &mx);
			sol = max(sol, prev_mx-mx);
			sol = max(sol, mn-prev_mn);
			prev_mn = mn;
			prev_mx = mx;
		}
		if (prev_mn != prev_mx) {
			sol = max(sol, prev_mx-prev_mn);
		}
		return sol;
	} else if (T == 2) {
		long long mn, mx;
		MinMax(MIN, MAX, &mn, &mx);
		long long diff = (mx-mn+1 + N-2)/(N-1), sol = 0, prev_mx = MAX, st = mn;
		while (st <= mx) {
			long long en = min(MAX, st+diff-1), cur_mn, cur_mx;
			MinMax(st,  en, &cur_mn, &cur_mx);
			if (cur_mn != -1) {
				sol = max(sol, cur_mn - prev_mx);
				prev_mx = cur_mx;
			}
			st += diff;
		}
		return sol;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
# Verdict Execution time Memory 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 1 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 1 ms 2392 KB Output is correct
16 Correct 9 ms 2392 KB Output is correct
17 Correct 7 ms 2392 KB Output is correct
18 Correct 6 ms 2524 KB Output is correct
19 Correct 7 ms 2392 KB Output is correct
20 Correct 6 ms 2392 KB Output is correct
21 Correct 25 ms 2768 KB Output is correct
22 Correct 26 ms 2644 KB Output is correct
23 Correct 27 ms 2644 KB Output is correct
24 Correct 25 ms 2648 KB Output is correct
25 Correct 23 ms 2644 KB Output is correct
26 Correct 25 ms 2648 KB Output is correct
27 Correct 25 ms 2648 KB Output is correct
28 Correct 25 ms 2648 KB Output is correct
29 Correct 26 ms 2648 KB Output is correct
30 Correct 20 ms 2648 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 Incorrect 0 ms 2392 KB Output isn't 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 2388 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 2 ms 2392 KB Output is correct
16 Correct 9 ms 2392 KB Output is correct
17 Correct 9 ms 2388 KB Output is correct
18 Correct 8 ms 2392 KB Output is correct
19 Correct 11 ms 2392 KB Output is correct
20 Correct 5 ms 2392 KB Output is correct
21 Correct 45 ms 2840 KB Output is correct
22 Correct 46 ms 2788 KB Output is correct
23 Correct 35 ms 2816 KB Output is correct
24 Correct 38 ms 2644 KB Output is correct
25 Correct 38 ms 2828 KB Output is correct
26 Correct 35 ms 2792 KB Output is correct
27 Correct 35 ms 2648 KB Output is correct
28 Correct 35 ms 2812 KB Output is correct
29 Correct 35 ms 2648 KB Output is correct
30 Correct 21 ms 2648 KB Output is correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct