Submission #992089

# Submission time Handle Problem Language Result Execution time Memory
992089 2024-06-03T21:19:29 Z MladenP Gap (APIO16_gap) C++17
30 / 100
46 ms 2860 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), 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+1;
		}
		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 1 ms 2388 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 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 2392 KB Output is correct
17 Correct 7 ms 2492 KB Output is correct
18 Correct 7 ms 2392 KB Output is correct
19 Correct 6 ms 2392 KB Output is correct
20 Correct 5 ms 2392 KB Output is correct
21 Correct 36 ms 2756 KB Output is correct
22 Correct 25 ms 2648 KB Output is correct
23 Correct 25 ms 2672 KB Output is correct
24 Correct 35 ms 2648 KB Output is correct
25 Correct 22 ms 2648 KB Output is correct
26 Correct 25 ms 2860 KB Output is correct
27 Correct 31 ms 2648 KB Output is correct
28 Correct 36 ms 2648 KB Output is correct
29 Correct 24 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 1 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 1 ms 2392 KB Output is correct
5 Correct 1 ms 2492 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 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 11 ms 2508 KB Output is correct
17 Correct 8 ms 2392 KB Output is correct
18 Correct 11 ms 2392 KB Output is correct
19 Correct 9 ms 2392 KB Output is correct
20 Correct 5 ms 2392 KB Output is correct
21 Correct 37 ms 2724 KB Output is correct
22 Correct 46 ms 2648 KB Output is correct
23 Correct 35 ms 2648 KB Output is correct
24 Correct 34 ms 2648 KB Output is correct
25 Correct 32 ms 2648 KB Output is correct
26 Correct 34 ms 2648 KB Output is correct
27 Correct 45 ms 2644 KB Output is correct
28 Correct 34 ms 2648 KB Output is correct
29 Correct 35 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 1 ms 2392 KB Output is correct