Submission #992085

# Submission time Handle Problem Language Result Execution time Memory
992085 2024-06-03T21:11:24 Z MladenP Gap (APIO16_gap) C++17
0 / 100
1363 ms 13528 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);
		while (prev_mn+1 <= prev_mx-1) {
			MinMax(prev_mn+1, prev_mx-1, &mn, &mx);
			if (mn != -1) {
				sol = max(sol, prev_mx-mx);
				sol = max(sol, mn-prev_mn);
			} else {
				sol = max(sol, prev_mx-prev_mn);
			}
			prev_mn = mn;
			prev_mx = mx;
		}
		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);
			cerr << st << ' ' << en << ' ' << cur_mn << ' ' << cur_mx << endl;
			if (cur_mn != -1) {
				sol = max(sol, cur_mn - prev_mx);
				prev_mx = cur_mx;
			}
			st += diff;
			cerr << "ST " << st << ' ' << mx << endl;
		}
		return sol;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 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 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 1 ms 2388 KB Output isn't correct
10 Correct 1 ms 2392 KB Output is correct
11 Incorrect 1 ms 2392 KB Output isn't correct
12 Incorrect 1 ms 2392 KB Output isn't correct
13 Incorrect 1 ms 2392 KB Output isn't correct
14 Incorrect 1 ms 2392 KB Output isn't correct
15 Incorrect 1 ms 2392 KB Output isn't correct
16 Incorrect 10 ms 2392 KB Output isn't correct
17 Incorrect 6 ms 2588 KB Output isn't correct
18 Incorrect 7 ms 2644 KB Output isn't correct
19 Incorrect 8 ms 2392 KB Output isn't correct
20 Correct 5 ms 2392 KB Output is correct
21 Incorrect 29 ms 2844 KB Output isn't correct
22 Incorrect 39 ms 2648 KB Output isn't correct
23 Incorrect 26 ms 2648 KB Output isn't correct
24 Incorrect 26 ms 2648 KB Output isn't correct
25 Incorrect 23 ms 2740 KB Output isn't correct
26 Incorrect 25 ms 2648 KB Output isn't correct
27 Incorrect 29 ms 2840 KB Output isn't correct
28 Incorrect 29 ms 2648 KB Output isn't correct
29 Incorrect 25 ms 2648 KB Output isn't correct
30 Correct 26 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 1 ms 2392 KB Output isn't correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 2 ms 2392 KB Output is correct
7 Correct 2 ms 2392 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 3 ms 2392 KB Output is correct
10 Correct 2 ms 2392 KB Output is correct
11 Correct 20 ms 2620 KB Output is correct
12 Correct 20 ms 2640 KB Output is correct
13 Correct 20 ms 2648 KB Output is correct
14 Correct 28 ms 2588 KB Output is correct
15 Correct 31 ms 2508 KB Output is correct
16 Correct 357 ms 5200 KB Output is correct
17 Correct 328 ms 5200 KB Output is correct
18 Correct 326 ms 4980 KB Output is correct
19 Correct 340 ms 4944 KB Output is correct
20 Correct 314 ms 3408 KB Output is correct
21 Correct 1363 ms 13136 KB Output is correct
22 Correct 1327 ms 13352 KB Output is correct
23 Correct 1317 ms 13172 KB Output is correct
24 Correct 1350 ms 13336 KB Output is correct
25 Correct 1348 ms 10588 KB Output is correct
26 Correct 1337 ms 13528 KB Output is correct
27 Correct 1328 ms 13196 KB Output is correct
28 Correct 1336 ms 13264 KB Output is correct
29 Correct 1340 ms 13136 KB Output is correct
30 Correct 1283 ms 6476 KB Output is correct
31 Correct 2 ms 2392 KB Output is correct
32 Correct 2 ms 2392 KB Output is correct