Submission #108461

# Submission time Handle Problem Language Result Execution time Memory
108461 2019-04-30T00:56:53 Z nxteru Gap (APIO16_gap) C++14
87.3918 / 100
79 ms 3312 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/=(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 3 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 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 384 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 2 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 15 ms 1024 KB Output is correct
17 Correct 16 ms 1152 KB Output is correct
18 Correct 16 ms 1116 KB Output is correct
19 Correct 17 ms 1068 KB Output is correct
20 Correct 13 ms 1068 KB Output is correct
21 Correct 53 ms 2716 KB Output is correct
22 Correct 54 ms 2716 KB Output is correct
23 Correct 53 ms 2732 KB Output is correct
24 Correct 56 ms 2688 KB Output is correct
25 Correct 51 ms 2740 KB Output is correct
26 Correct 52 ms 2632 KB Output is correct
27 Correct 48 ms 2716 KB Output is correct
28 Correct 54 ms 2844 KB Output is correct
29 Correct 53 ms 2712 KB Output is correct
30 Correct 40 ms 2844 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 2 ms 384 KB Output is correct
3 Correct 3 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 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 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 256 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 18 ms 896 KB Output is correct
17 Correct 18 ms 888 KB Output is correct
18 Correct 21 ms 896 KB Output is correct
19 Correct 20 ms 896 KB Output is correct
20 Partially correct 9 ms 512 KB Partially correct
21 Correct 73 ms 2288 KB Output is correct
22 Correct 66 ms 2288 KB Output is correct
23 Correct 72 ms 2412 KB Output is correct
24 Correct 65 ms 2288 KB Output is correct
25 Correct 64 ms 3312 KB Output is correct
26 Correct 65 ms 2332 KB Output is correct
27 Correct 79 ms 2260 KB Output is correct
28 Correct 64 ms 2472 KB Output is correct
29 Correct 72 ms 2288 KB Output is correct
30 Partially correct 57 ms 1528 KB Partially correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct