Submission #105009

# Submission time Handle Problem Language Result Execution time Memory
105009 2019-04-10T06:28:07 Z puyu_liao Gap (APIO16_gap) C++14
100 / 100
85 ms 2812 KB
#include<bits/stdc++.h>
using namespace std;
#include "gap.h"
typedef long long ll;
 
ll findGap(int T,int n){
	if(T==1){
		vector<ll> v1,v2;
		ll ans = 0;
		ll s = 0, t = 1000000000000000000ll,mn,mx;
		for(int i=1,j=n;i<=j;i++,j--){
			MinMax(s,t,&mn,&mx);
			v1.push_back(mn);
			if(i != j) v2.push_back(mx);
			s = mn+1; t=mx-1;
		}
		reverse(v2.begin(),v2.end());
		for(ll i : v2) v1.push_back(i);
		for(int i=0;i<v1.size()-1;i++) ans = max(ans,v1[i+1]-v1[i]);
		return ans;
	}
	else{
		ll ans = 0;
		ll s = 0,t=1000000000000000000ll,mn,mx,gap,last;
		MinMax(s,t,&mn,&mx);
		s = mn + 1, t = mx - 1;
		if(n == 2) return mx - mn;
		gap = (mx-mn+1)/(n);
		last = mn;
		while(s + gap + 1 <= t){
			MinMax(s,s + gap,&mn,&mx);
			if(mn != -1) ans = max(ans,mn - last),last = mx;
			s += gap+1;
		}
		MinMax(s,t,&mn,&mx);
		if(mn != -1) ans = max(ans,mn - last),last = mx;
		ans = max(ans,t+1 - last);
		return ans;
	}
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:19:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<v1.size()-1;i++) ans = max(ans,v1[i+1]-v1[i]);
               ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 356 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 3 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 4 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 14 ms 1068 KB Output is correct
19 Correct 14 ms 1068 KB Output is correct
20 Correct 12 ms 1068 KB Output is correct
21 Correct 47 ms 2716 KB Output is correct
22 Correct 64 ms 2764 KB Output is correct
23 Correct 55 ms 2716 KB Output is correct
24 Correct 55 ms 2812 KB Output is correct
25 Correct 46 ms 2720 KB Output is correct
26 Correct 53 ms 2716 KB Output is correct
27 Correct 53 ms 2716 KB Output is correct
28 Correct 55 ms 2720 KB Output is correct
29 Correct 55 ms 2716 KB Output is correct
30 Correct 38 ms 2716 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 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 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 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 396 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 20 ms 572 KB Output is correct
17 Correct 19 ms 512 KB Output is correct
18 Correct 18 ms 512 KB Output is correct
19 Correct 17 ms 512 KB Output is correct
20 Correct 10 ms 512 KB Output is correct
21 Correct 68 ms 1272 KB Output is correct
22 Correct 71 ms 1152 KB Output is correct
23 Correct 75 ms 1116 KB Output is correct
24 Correct 66 ms 1152 KB Output is correct
25 Correct 59 ms 1144 KB Output is correct
26 Correct 65 ms 1144 KB Output is correct
27 Correct 72 ms 1144 KB Output is correct
28 Correct 85 ms 1144 KB Output is correct
29 Correct 76 ms 1144 KB Output is correct
30 Correct 35 ms 1152 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct