Submission #758698

# Submission time Handle Problem Language Result Execution time Memory
758698 2023-06-15T06:55:51 Z Trisanu_Das Gap (APIO16_gap) C++17
100 / 100
47 ms 1120 KB
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const ll INF=1e18;

ll findGap(int T, int N){
	ll mn, mx;
	MinMax(0, INF, &mn, &mx);
	if(N == 2)return mx - mn;
	if(T == 1){
		ll MN, MX, Ans=0;
		N = (N - 1) / 2;
		while(N--) MinMax(mn + 1, mx - 1, &MN, &MX), Ans = max(Ans, max(mx - MX - (ll)(MX == -1) * INF, MN - mn)), mn = MN, mx = MX;
		return max(Ans, mx - mn);
	}
	ll l=mn, r=mx, ans=(mx-mn+1)/((ll)N)+1, Ans=0, MX=mn;
	for (ll i=0; i<N; i++)
		MinMax(l+1+i*ans, l+(i+1)*ans, &mn, &mx),
		Ans=max(Ans, mn-MX),
		MX=max(MX, mx);
	return Ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:18:11: warning: unused variable 'r' [-Wunused-variable]
   18 |  ll l=mn, r=mx, ans=(mx-mn+1)/((ll)N)+1, Ans=0, MX=mn;
      |           ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 8 ms 464 KB Output is correct
17 Correct 7 ms 464 KB Output is correct
18 Correct 8 ms 464 KB Output is correct
19 Correct 8 ms 428 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 36 ms 1088 KB Output is correct
22 Correct 33 ms 1120 KB Output is correct
23 Correct 30 ms 968 KB Output is correct
24 Correct 30 ms 1064 KB Output is correct
25 Correct 27 ms 996 KB Output is correct
26 Correct 30 ms 1064 KB Output is correct
27 Correct 29 ms 1064 KB Output is correct
28 Correct 32 ms 1056 KB Output is correct
29 Correct 30 ms 1064 KB Output is correct
30 Correct 28 ms 1060 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 10 ms 432 KB Output is correct
17 Correct 11 ms 464 KB Output is correct
18 Correct 10 ms 428 KB Output is correct
19 Correct 10 ms 508 KB Output is correct
20 Correct 5 ms 464 KB Output is correct
21 Correct 40 ms 1068 KB Output is correct
22 Correct 41 ms 1084 KB Output is correct
23 Correct 40 ms 968 KB Output is correct
24 Correct 44 ms 1096 KB Output is correct
25 Correct 39 ms 1092 KB Output is correct
26 Correct 40 ms 1056 KB Output is correct
27 Correct 40 ms 1044 KB Output is correct
28 Correct 47 ms 1052 KB Output is correct
29 Correct 42 ms 1084 KB Output is correct
30 Correct 24 ms 1056 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct