Submission #108462

# Submission time Handle Problem Language Result Execution time Memory
108462 2019-04-30T00:58:47 Z nxteru Gap (APIO16_gap) C++14
89.0376 / 100
73 ms 3308 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;
		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:31: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 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 4 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 18 ms 1068 KB Output is correct
17 Correct 16 ms 1068 KB Output is correct
18 Correct 15 ms 1068 KB Output is correct
19 Correct 15 ms 1068 KB Output is correct
20 Correct 11 ms 1064 KB Output is correct
21 Correct 54 ms 2692 KB Output is correct
22 Correct 56 ms 2716 KB Output is correct
23 Correct 56 ms 2712 KB Output is correct
24 Correct 56 ms 2844 KB Output is correct
25 Correct 51 ms 2716 KB Output is correct
26 Correct 54 ms 2716 KB Output is correct
27 Correct 56 ms 2716 KB Output is correct
28 Correct 58 ms 2716 KB Output is correct
29 Correct 47 ms 2752 KB Output is correct
30 Correct 38 ms 2716 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 452 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 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 3 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 3 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 4 ms 384 KB Output is correct
16 Correct 19 ms 1064 KB Output is correct
17 Correct 19 ms 1024 KB Output is correct
18 Correct 22 ms 1024 KB Output is correct
19 Correct 18 ms 896 KB Output is correct
20 Partially correct 12 ms 548 KB Partially correct
21 Correct 70 ms 2260 KB Output is correct
22 Correct 72 ms 2288 KB Output is correct
23 Correct 68 ms 2288 KB Output is correct
24 Correct 70 ms 2288 KB Output is correct
25 Correct 65 ms 3308 KB Output is correct
26 Correct 66 ms 2288 KB Output is correct
27 Correct 73 ms 2288 KB Output is correct
28 Correct 67 ms 2288 KB Output is correct
29 Correct 71 ms 2288 KB Output is correct
30 Partially correct 38 ms 1540 KB Partially correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct