Submission #242070

# Submission time Handle Problem Language Result Execution time Memory
242070 2020-06-26T16:18:11 Z michao Gap (APIO16_gap) C++14
100 / 100
77 ms 3360 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
#define pb push_back
int n;
ll mini,maxi;
vector<ll>pom,answer;
long long findGap(int t, int N)
{
	n=N;
	ll ans=0;
	ll ip=-1,ik=1e19;
	if (t==1)
	{
		while ((int)answer.size()+(int)pom.size()<n)
		{
			ip++,ik--;
			MinMax(ip,ik,&ip,&ik);
			answer.pb(ip);
			pom.pb(ik);
		}
	}
	else
	{
		MinMax(ip,ik,&ip,&ik);
		answer.pb(ip),pom.pb(ik);
		ll gap=(ik-ip+1)/n+1;
		for (ll i=ip;i+1<ik;i+=gap)
		{
			ll news=min(ik-1,i+gap);
			MinMax(i+1,news,&mini,&maxi);
			if (mini!=-1)answer.pb(mini);
			if (maxi!=-1)answer.pb(maxi);
		}
	}
	while ((int)pom.size()>0)answer.pb(pom.back()),pom.pop_back();
	for (int i=0;i<(int)answer.size()-1;i++)ans=max(ans,answer[i+1]-answer[i]);
	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:13:14: warning: overflow in implicit constant conversion [-Woverflow]
  ll ip=-1,ik=1e19;
              ^~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 17 ms 1024 KB Output is correct
17 Correct 17 ms 1024 KB Output is correct
18 Correct 17 ms 1068 KB Output is correct
19 Correct 17 ms 1068 KB Output is correct
20 Correct 13 ms 1068 KB Output is correct
21 Correct 56 ms 2716 KB Output is correct
22 Correct 54 ms 2716 KB Output is correct
23 Correct 64 ms 2716 KB Output is correct
24 Correct 58 ms 2772 KB Output is correct
25 Correct 54 ms 2692 KB Output is correct
26 Correct 57 ms 2628 KB Output is correct
27 Correct 57 ms 2720 KB Output is correct
28 Correct 58 ms 2872 KB Output is correct
29 Correct 58 ms 2628 KB Output is correct
30 Correct 43 ms 2716 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 416 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 20 ms 896 KB Output is correct
17 Correct 21 ms 1024 KB Output is correct
18 Correct 20 ms 896 KB Output is correct
19 Correct 20 ms 896 KB Output is correct
20 Correct 13 ms 512 KB Output is correct
21 Correct 72 ms 2264 KB Output is correct
22 Correct 71 ms 2288 KB Output is correct
23 Correct 76 ms 2268 KB Output is correct
24 Correct 72 ms 2288 KB Output is correct
25 Correct 70 ms 3360 KB Output is correct
26 Correct 71 ms 2288 KB Output is correct
27 Correct 71 ms 2288 KB Output is correct
28 Correct 75 ms 2288 KB Output is correct
29 Correct 77 ms 2356 KB Output is correct
30 Correct 46 ms 1488 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct