Submission #1099541

# Submission time Handle Problem Language Result Execution time Memory
1099541 2024-10-11T14:35:19 Z KasymK Gap (APIO16_gap) C++17
100 / 100
42 ms 1880 KB
#include "bits/stdc++.h"
#include "gap.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int MOD = 1e9+7;
const int N = 1e5+5;
ll a[N];
 
ll findGap(int t, int n){
	if(t == 1){
		ll l = 0, r = 1e18, id = 0, mn, mx, ans = 0;
        for(int i = 0; i < (n+1)/2; ++i){
            MinMax(l, r, &mn, &mx);
            a[id++] = mn, a[id++] = mx, l = mn+1, r = mx-1;
        }
        sort(a, a+n);
        for(int i = 0; i < n-1; ++i)
        	umax(ans, a[i+1]-a[i]);
        return ans;
    }
    ll s, T;
	MinMax(0, LLONG_MAX, &s, &T);	//n + 1
 
	ll d = (T-s+n)/(n-1), mx = 0, a = s;
	while(s + 1 < T){
		ll x, y;
		MinMax(s+1, min(s+d, T-1), &x, &y);
		if(~x){
			umax(mx, x-a);
          	a = y;
		}
		s += d;
	}
  umax(mx, T-a);
  return mx;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 432 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 7 ms 820 KB Output is correct
17 Correct 7 ms 600 KB Output is correct
18 Correct 10 ms 600 KB Output is correct
19 Correct 9 ms 736 KB Output is correct
20 Correct 7 ms 600 KB Output is correct
21 Correct 28 ms 1880 KB Output is correct
22 Correct 28 ms 1812 KB Output is correct
23 Correct 28 ms 1880 KB Output is correct
24 Correct 28 ms 1872 KB Output is correct
25 Correct 25 ms 1872 KB Output is correct
26 Correct 37 ms 1808 KB Output is correct
27 Correct 30 ms 1872 KB Output is correct
28 Correct 30 ms 1880 KB Output is correct
29 Correct 30 ms 1784 KB Output is correct
30 Correct 25 ms 1880 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 9 ms 440 KB Output is correct
17 Correct 9 ms 600 KB Output is correct
18 Correct 11 ms 600 KB Output is correct
19 Correct 10 ms 600 KB Output is correct
20 Correct 5 ms 600 KB Output is correct
21 Correct 35 ms 1196 KB Output is correct
22 Correct 35 ms 1012 KB Output is correct
23 Correct 35 ms 1024 KB Output is correct
24 Correct 42 ms 1112 KB Output is correct
25 Correct 32 ms 1112 KB Output is correct
26 Correct 38 ms 1112 KB Output is correct
27 Correct 34 ms 1064 KB Output is correct
28 Correct 35 ms 1112 KB Output is correct
29 Correct 35 ms 1112 KB Output is correct
30 Correct 23 ms 1112 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct