Submission #41248

# Submission time Handle Problem Language Result Execution time Memory
41248 2018-02-15T06:36:04 Z Just_Solve_The_Problem Gap (APIO16_gap) C++11
0 / 100
94 ms 2284 KB
#include <gap.h>
#include <bits/stdc++.h> 

#define ll long long

using namespace std;

ll solve1(int n) {
	long long left;
	long long right;
	left = 0;
	right = 1e18;
	long long mn = 0, mx = 1e18;        
	long long vec[n];
	int cnt = 0;
	int cn = n - 1;
	while (mn < mx) {
		MinMax(left, right, &mn, &mx);
		vec[cnt++] = mn; 
		if (mn != mx)
			vec[cn--] = mx;
		left = mn + 1;
		right = mx - 1;	
	}                  
	long long ans = 0;
	for (int i = 1; i < n; i++) {         
		if (vec[i] - vec[i - 1] > ans) {
			ans = vec[i] - vec[i - 1];
		}
	}
	return ans;
}

ll findGap(int t, int n) {
	if (t == 1) {
		return solve1(n);
	}
	ll l, r;
	MinMax(0, 1e18, &l, &r);
	if (n == 2) {
		return r - l;
	}
	ll dif = (r - l + n) / n;
	l++; r--;
	ll start = l;
	ll fin = start + dif - 1;
	ll fre = 0;
	ll mx = 0; 
	ll ans = 0;
	while (1) {
		ll l1, r1;
		MinMax(start, fin, &l1, &r1);
		if (l1 == -1) {
			fre += dif;
		} else {
			if (fre != 0) {
				ans = max(ans, fre + mx + (l1 - start + 1));
			}
			fre = 0;             
			mx = fin - r1;
		}
		if (fin == r) break;      
		start = fin + 1;
		fin = min(start + dif - 1, r);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 1 ms 552 KB Output is correct
4 Correct 1 ms 552 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Incorrect 1 ms 552 KB Output isn't correct
7 Incorrect 2 ms 568 KB Output isn't correct
8 Incorrect 1 ms 584 KB Output isn't correct
9 Incorrect 2 ms 584 KB Output isn't correct
10 Runtime error 1 ms 708 KB Execution failed because the return code was nonzero
11 Incorrect 2 ms 708 KB Output isn't correct
12 Incorrect 2 ms 712 KB Output isn't correct
13 Incorrect 2 ms 712 KB Output isn't correct
14 Incorrect 2 ms 712 KB Output isn't correct
15 Incorrect 2 ms 712 KB Output isn't correct
16 Incorrect 14 ms 880 KB Output isn't correct
17 Incorrect 14 ms 972 KB Output isn't correct
18 Incorrect 15 ms 972 KB Output isn't correct
19 Incorrect 14 ms 972 KB Output isn't correct
20 Runtime error 11 ms 972 KB Execution failed because the return code was nonzero
21 Incorrect 53 ms 2100 KB Output isn't correct
22 Incorrect 65 ms 2156 KB Output isn't correct
23 Incorrect 53 ms 2284 KB Output isn't correct
24 Incorrect 54 ms 2284 KB Output isn't correct
25 Incorrect 46 ms 2284 KB Output isn't correct
26 Incorrect 55 ms 2284 KB Output isn't correct
27 Incorrect 55 ms 2284 KB Output isn't correct
28 Incorrect 54 ms 2284 KB Output isn't correct
29 Incorrect 54 ms 2284 KB Output isn't correct
30 Runtime error 39 ms 2284 KB Execution failed because the return code was nonzero
31 Runtime error 2 ms 2284 KB Execution failed because the return code was nonzero
32 Runtime error 1 ms 2284 KB Execution failed because the return code was nonzero
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2284 KB Output is correct
2 Correct 1 ms 2284 KB Output is correct
3 Correct 1 ms 2284 KB Output is correct
4 Correct 1 ms 2284 KB Output is correct
5 Correct 2 ms 2284 KB Output is correct
6 Correct 2 ms 2284 KB Output is correct
7 Correct 1 ms 2284 KB Output is correct
8 Correct 2 ms 2284 KB Output is correct
9 Correct 2 ms 2284 KB Output is correct
10 Correct 1 ms 2284 KB Output is correct
11 Correct 2 ms 2284 KB Output is correct
12 Correct 3 ms 2284 KB Output is correct
13 Correct 3 ms 2284 KB Output is correct
14 Correct 3 ms 2284 KB Output is correct
15 Correct 3 ms 2284 KB Output is correct
16 Correct 20 ms 2284 KB Output is correct
17 Correct 20 ms 2284 KB Output is correct
18 Correct 19 ms 2284 KB Output is correct
19 Correct 19 ms 2284 KB Output is correct
20 Correct 10 ms 2284 KB Output is correct
21 Correct 94 ms 2284 KB Output is correct
22 Correct 73 ms 2284 KB Output is correct
23 Correct 76 ms 2284 KB Output is correct
24 Correct 76 ms 2284 KB Output is correct
25 Correct 66 ms 2284 KB Output is correct
26 Correct 75 ms 2284 KB Output is correct
27 Correct 79 ms 2284 KB Output is correct
28 Correct 72 ms 2284 KB Output is correct
29 Correct 73 ms 2284 KB Output is correct
30 Correct 40 ms 2284 KB Output is correct
31 Incorrect 1 ms 2284 KB Output isn't correct
32 Correct 1 ms 2284 KB Output is correct