Submission #992088

# Submission time Handle Problem Language Result Execution time Memory
992088 2024-06-03T21:17:33 Z MladenP Gap (APIO16_gap) C++17
83.5083 / 100
40 ms 2864 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 + 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 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 1 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 6 ms 2544 KB Output is correct
17 Correct 9 ms 2392 KB Output is correct
18 Correct 7 ms 2536 KB Output is correct
19 Correct 7 ms 2560 KB Output is correct
20 Correct 5 ms 2472 KB Output is correct
21 Correct 26 ms 2660 KB Output is correct
22 Correct 25 ms 2864 KB Output is correct
23 Correct 25 ms 2648 KB Output is correct
24 Correct 25 ms 2648 KB Output is correct
25 Correct 24 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 25 ms 2648 KB Output is correct
30 Correct 23 ms 2648 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 Partially correct 0 ms 2392 KB Partially correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Partially correct 0 ms 2392 KB Partially 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 2512 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Partially correct 1 ms 2392 KB Partially correct
16 Correct 10 ms 2536 KB Output is correct
17 Correct 9 ms 2392 KB Output is correct
18 Correct 8 ms 2392 KB Output is correct
19 Correct 11 ms 2644 KB Output is correct
20 Correct 5 ms 2392 KB Output is correct
21 Correct 36 ms 2720 KB Output is correct
22 Correct 34 ms 2648 KB Output is correct
23 Correct 35 ms 2648 KB Output is correct
24 Correct 35 ms 2648 KB Output is correct
25 Partially correct 40 ms 2644 KB Partially correct
26 Correct 38 ms 2824 KB Output is correct
27 Correct 36 ms 2772 KB Output is correct
28 Correct 36 ms 2648 KB Output is correct
29 Correct 36 ms 2648 KB Output is correct
30 Correct 21 ms 2648 KB Output is correct
31 Partially correct 1 ms 2392 KB Partially correct
32 Partially correct 0 ms 2392 KB Partially correct