Submission #108460

# Submission time Handle Problem Language Result Execution time Memory
108460 2019-04-30T00:51:06 Z nxteru Gap (APIO16_gap) C++14
89.0376 / 100
84 ms 3280 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
#define PB push_back
ll ans,mn,mx,n,l=-1,r=1e19+1;
vector<ll>x,y;
long long findGap(int t, int N)
{
	n=N;
	if(t==1){
		while(x.size()+y.size()<n){
			l++,r--;
			MinMax(l,r,&l,&r);
			x.PB(l);
			y.PB(r);
		}
	}else{
		MinMax(l,r,&l,&r);
		x.PB(l),y.PB(r);
		ll s=r-l+1LL;
		s-=n;
		s=(s+n-2LL)/(n-1LL);
		for(ll i=l;i+1<r;i+=s){
			ll nx=min(r-1,i+s);
			MinMax(i+1,nx,&mn,&mx);
			if(mn!=-1)x.PB(mn);
			if(mx!=-1)x.PB(mx);
		}
	}
	for(int i=y.size()-1;i>=0;i--)x.PB(y[i]);
	for(int i=0;i+1<x.size();i++)ans=max(ans,x[i+1]-x[i]);
	return ans;
}

Compilation message

gap.cpp:6:27: warning: overflow in implicit constant conversion [-Woverflow]
 ll ans,mn,mx,n,l=-1,r=1e19+1;
                       ~~~~^~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:12:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(x.size()+y.size()<n){
         ~~~~~~~~~~~~~~~~~^~
gap.cpp:32:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i+1<x.size();i++)ans=max(ans,x[i+1]-x[i]);
              ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 20 ms 1016 KB Output is correct
17 Correct 14 ms 1024 KB Output is correct
18 Correct 14 ms 1068 KB Output is correct
19 Correct 14 ms 1024 KB Output is correct
20 Correct 11 ms 1068 KB Output is correct
21 Correct 54 ms 2868 KB Output is correct
22 Correct 52 ms 2688 KB Output is correct
23 Correct 53 ms 2716 KB Output is correct
24 Correct 49 ms 2844 KB Output is correct
25 Correct 56 ms 2784 KB Output is correct
26 Correct 56 ms 2716 KB Output is correct
27 Correct 54 ms 2716 KB Output is correct
28 Correct 48 ms 2716 KB Output is correct
29 Correct 53 ms 2716 KB Output is correct
30 Correct 42 ms 2844 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 356 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 17 ms 1024 KB Output is correct
17 Correct 17 ms 896 KB Output is correct
18 Correct 17 ms 896 KB Output is correct
19 Correct 18 ms 1016 KB Output is correct
20 Partially correct 8 ms 512 KB Partially correct
21 Correct 75 ms 2288 KB Output is correct
22 Correct 68 ms 2288 KB Output is correct
23 Correct 65 ms 2228 KB Output is correct
24 Correct 67 ms 2288 KB Output is correct
25 Correct 81 ms 3280 KB Output is correct
26 Correct 84 ms 2416 KB Output is correct
27 Correct 70 ms 2288 KB Output is correct
28 Correct 69 ms 2284 KB Output is correct
29 Correct 68 ms 2260 KB Output is correct
30 Partially correct 37 ms 1528 KB Partially correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct