Submission #344172

# Submission time Handle Problem Language Result Execution time Memory
344172 2021-01-05T08:14:17 Z juggernaut Gap (APIO16_gap) C++14
100 / 100
68 ms 3272 KB
#include<bits/stdc++.h>
#include"gap.h"
#ifdef EVAL
#else
#include"grader.cpp"
#endif
using namespace std;
typedef long long ll;
ll ans,mn,mx,n,l=-1,r=1e19+1;
vector<ll>x,y;
ll findGap(int t, int N){
	n=N;
	if(t==1){
		while(x.size()+y.size()<n){
			l++,r--;
			MinMax(l,r,&l,&r);
			x.push_back(l);
			y.push_back(r);
		}
	}else{
		MinMax(l,r,&l,&r);
		x.push_back(l),y.push_back(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.push_back(mn);
			if(mx!=-1)x.push_back(mx);
		}
    }
  for(int i=y.size()-1;i>=0;i--)x.push_back(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:9:27: warning: overflow in conversion from 'double' to 'll' {aka 'long long int'} changes value from '1.0e+19' to '9223372036854775807' [-Woverflow]
    9 | ll ans,mn,mx,n,l=-1,r=1e19+1;
      |                       ~~~~^~
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:14:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   14 |   while(x.size()+y.size()<n){
      |         ~~~~~~~~~~~~~~~~~^~
gap.cpp:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  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 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 13 ms 1048 KB Output is correct
17 Correct 11 ms 1124 KB Output is correct
18 Correct 11 ms 1004 KB Output is correct
19 Correct 13 ms 1068 KB Output is correct
20 Correct 9 ms 1004 KB Output is correct
21 Correct 50 ms 2704 KB Output is correct
22 Correct 45 ms 2704 KB Output is correct
23 Correct 44 ms 2704 KB Output is correct
24 Correct 44 ms 2704 KB Output is correct
25 Correct 39 ms 2704 KB Output is correct
26 Correct 44 ms 2784 KB Output is correct
27 Correct 44 ms 2688 KB Output is correct
28 Correct 46 ms 2704 KB Output is correct
29 Correct 44 ms 2852 KB Output is correct
30 Correct 36 ms 2704 KB Output is correct
31 Correct 0 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 15 ms 876 KB Output is correct
17 Correct 15 ms 876 KB Output is correct
18 Correct 15 ms 876 KB Output is correct
19 Correct 16 ms 876 KB Output is correct
20 Correct 8 ms 620 KB Output is correct
21 Correct 62 ms 2276 KB Output is correct
22 Correct 65 ms 2344 KB Output is correct
23 Correct 61 ms 2240 KB Output is correct
24 Correct 61 ms 2276 KB Output is correct
25 Correct 62 ms 3272 KB Output is correct
26 Correct 68 ms 2276 KB Output is correct
27 Correct 63 ms 2384 KB Output is correct
28 Correct 62 ms 2264 KB Output is correct
29 Correct 62 ms 2356 KB Output is correct
30 Correct 35 ms 1516 KB Output is correct
31 Correct 0 ms 364 KB Output is correct
32 Correct 0 ms 364 KB Output is correct