Submission #516864

# Submission time Handle Problem Language Result Execution time Memory
516864 2022-01-22T07:46:20 Z CSQ31 Gap (APIO16_gap) C++17
100 / 100
61 ms 3212 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
long long findGap(int T, int N)
{
	if(T==1){
		ll l = 0,r = 1e18;
		vector<ll>a,b;
		while(r>=l && a.size() + b.size() < N){
			ll mn,mx;
			MinMax(l,r,&mn,&mx);
			if(mn==-1)break;
			if(mn==mx){
				a.push_back(mn);
				break;
			}else{
				a.push_back(mn);
				b.push_back(mx);	
			}
			l = mn+1;
			r = mx-1;
		}
		reverse(b.begin(),b.end());
		for(auto x:b)a.push_back(x);
		ll ans = 0;
		for(int i=0;i+1<N;i++)ans = max(ans,a[i+1]-a[i]);
		return ans;
	}
	else{
		ll mn,mx;
		MinMax(0,1e18,&mn,&mx);
		ll x = (mx-mn+N-1) /(N-1);
		vector<ll>a;
		for(ll l=mn;l<=mx;){
			ll c,d;
			MinMax(l,min(l+x-1,mx),&c,&d);
			l = max(d+1,l+x);
			if(c == -1)continue;
			a.push_back(c);
			a.push_back(d);
		}		
		ll ans = 0;
		for(int i=0;i+1<(int)(a.size());i++)ans = max(ans,a[i+1]-a[i]);
		return ans;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:10:37: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |   while(r>=l && a.size() + b.size() < N){
      |                 ~~~~~~~~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 2 ms 328 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 10 ms 968 KB Output is correct
17 Correct 9 ms 976 KB Output is correct
18 Correct 9 ms 976 KB Output is correct
19 Correct 10 ms 968 KB Output is correct
20 Correct 7 ms 964 KB Output is correct
21 Correct 38 ms 2620 KB Output is correct
22 Correct 44 ms 2620 KB Output is correct
23 Correct 35 ms 2616 KB Output is correct
24 Correct 35 ms 2652 KB Output is correct
25 Correct 38 ms 2548 KB Output is correct
26 Correct 36 ms 2624 KB Output is correct
27 Correct 34 ms 2620 KB Output is correct
28 Correct 35 ms 2556 KB Output is correct
29 Correct 37 ms 2612 KB Output is correct
30 Correct 27 ms 2612 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 15 ms 872 KB Output is correct
17 Correct 12 ms 848 KB Output is correct
18 Correct 12 ms 820 KB Output is correct
19 Correct 12 ms 868 KB Output is correct
20 Correct 7 ms 456 KB Output is correct
21 Correct 52 ms 2160 KB Output is correct
22 Correct 58 ms 2192 KB Output is correct
23 Correct 52 ms 2188 KB Output is correct
24 Correct 49 ms 2192 KB Output is correct
25 Correct 52 ms 3212 KB Output is correct
26 Correct 61 ms 2152 KB Output is correct
27 Correct 51 ms 2196 KB Output is correct
28 Correct 48 ms 2232 KB Output is correct
29 Correct 54 ms 2232 KB Output is correct
30 Correct 29 ms 1436 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct