Submission #108463

# Submission time Handle Problem Language Result Execution time Memory
108463 2019-04-30T01:09:27 Z nxteru Gap (APIO16_gap) C++14
100 / 100
78 ms 3304 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++;
		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 384 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 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 356 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 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 14 ms 1024 KB Output is correct
17 Correct 14 ms 1024 KB Output is correct
18 Correct 15 ms 1024 KB Output is correct
19 Correct 19 ms 1024 KB Output is correct
20 Correct 11 ms 1068 KB Output is correct
21 Correct 53 ms 2692 KB Output is correct
22 Correct 53 ms 2716 KB Output is correct
23 Correct 57 ms 2716 KB Output is correct
24 Correct 57 ms 2640 KB Output is correct
25 Correct 47 ms 2632 KB Output is correct
26 Correct 68 ms 2748 KB Output is correct
27 Correct 60 ms 2892 KB Output is correct
28 Correct 54 ms 2716 KB Output is correct
29 Correct 59 ms 2716 KB Output is correct
30 Correct 38 ms 2716 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 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 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 412 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 23 ms 896 KB Output is correct
17 Correct 20 ms 896 KB Output is correct
18 Correct 19 ms 1024 KB Output is correct
19 Correct 19 ms 896 KB Output is correct
20 Correct 9 ms 512 KB Output is correct
21 Correct 66 ms 2288 KB Output is correct
22 Correct 71 ms 2288 KB Output is correct
23 Correct 75 ms 2364 KB Output is correct
24 Correct 71 ms 2260 KB Output is correct
25 Correct 67 ms 3304 KB Output is correct
26 Correct 74 ms 2288 KB Output is correct
27 Correct 75 ms 2288 KB Output is correct
28 Correct 78 ms 2256 KB Output is correct
29 Correct 67 ms 2288 KB Output is correct
30 Correct 36 ms 1528 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct