Submission #960055

# Submission time Handle Problem Language Result Execution time Memory
960055 2024-04-09T15:06:56 Z kim Gap (APIO16_gap) C++17
56.3543 / 100
40 ms 4240 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define eb emplace_back

long long findGap(int T, int N)
{
	if(T==1){
		ll a=1,b=1e18;
		vector<ll> vec;
		for(int i=0;i<N+1>>1;++i){
			MinMax(a,b,&a,&b);
			if(a==b) vec.eb(a);
			else vec.eb(a++), vec.eb(b--);
		}
		sort(vec.begin(),vec.end());
		ll ans=0;
		for(int i=1;i<vec.size();++i) ans=max(ans,vec[i]-vec[i-1]);
		return ans;
	}
	ll a,b,c,d;
	MinMax(1,1e18,&a,&b);
	if(N==2) return b-a;
	ll ans=(b-a+N-2)/(N-1);
	while(a+ans<b){
		MinMax(a+1,a+ans,&c,&d);
		if(d!=-1) a=d;
		else{
			MinMax(b-ans,b-1,&c,&d);
			if(d!=-1) b=c;
			else if(b-ans<=a+ans+1){
				ans=b-a;
				break;
			}
			else{
				MinMax(a+1,b-1,&c,&d);
				if(d!=-1){
					ans=max(c-a,b-d);
					a=c;
					b=d;
				}
				else{
					ans=b-a;
					break;
				}
			}
		}
	}
	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:12:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   12 |   for(int i=0;i<N+1>>1;++i){
      |                 ~^~
gap.cpp:19:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for(int i=1;i<vec.size();++i) ans=max(ans,vec[i]-vec[i-1]);
      |               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
3 Correct 2 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 2 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 2 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 2 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 8 ms 2836 KB Output is correct
17 Correct 8 ms 2840 KB Output is correct
18 Correct 9 ms 2904 KB Output is correct
19 Correct 9 ms 2992 KB Output is correct
20 Correct 7 ms 2824 KB Output is correct
21 Correct 33 ms 4088 KB Output is correct
22 Correct 32 ms 4240 KB Output is correct
23 Correct 32 ms 3996 KB Output is correct
24 Correct 33 ms 3948 KB Output is correct
25 Correct 29 ms 3992 KB Output is correct
26 Correct 32 ms 3996 KB Output is correct
27 Correct 32 ms 4164 KB Output is correct
28 Correct 32 ms 4124 KB Output is correct
29 Correct 32 ms 4008 KB Output is correct
30 Correct 26 ms 3992 KB Output is correct
31 Correct 1 ms 2448 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Partially correct 0 ms 2392 KB Partially correct
3 Partially correct 1 ms 2392 KB Partially correct
4 Partially correct 0 ms 2392 KB Partially correct
5 Correct 0 ms 2392 KB Output is correct
6 Partially correct 1 ms 2392 KB Partially correct
7 Partially correct 1 ms 2392 KB Partially correct
8 Partially correct 1 ms 2392 KB Partially correct
9 Partially correct 1 ms 2392 KB Partially correct
10 Correct 0 ms 2392 KB Output is correct
11 Partially correct 1 ms 2392 KB Partially correct
12 Partially correct 1 ms 2392 KB Partially correct
13 Partially correct 1 ms 2392 KB Partially correct
14 Partially correct 1 ms 2392 KB Partially correct
15 Correct 1 ms 2392 KB Output is correct
16 Partially correct 5 ms 2584 KB Partially correct
17 Partially correct 5 ms 2584 KB Partially correct
18 Partially correct 5 ms 2556 KB Partially correct
19 Partially correct 5 ms 2592 KB Partially correct
20 Correct 3 ms 2568 KB Output is correct
21 Partially correct 18 ms 2844 KB Partially correct
22 Partially correct 18 ms 2852 KB Partially correct
23 Partially correct 17 ms 3020 KB Partially correct
24 Partially correct 18 ms 2852 KB Partially correct
25 Correct 40 ms 2856 KB Output is correct
26 Partially correct 22 ms 3100 KB Partially correct
27 Partially correct 18 ms 2744 KB Partially correct
28 Partially correct 18 ms 2852 KB Partially correct
29 Partially correct 18 ms 2856 KB Partially correct
30 Correct 11 ms 2844 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct