Submission #835920

# Submission time Handle Problem Language Result Execution time Memory
835920 2023-08-23T22:56:07 Z BT21tata Gap (APIO16_gap) C++17
100 / 100
42 ms 2220 KB
#include "gap.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
		
vector<ll>v;
ll mn, mx;
 
long long findGap(int T, int n)
{
	if(T==1)
	{
		ll l=0, r=1e18, ret=0;
		while(v.size()<n)
		{
			MinMax(l, r, &mn, &mx);
			v.pb(mn); v.pb(mx);
			l=mn+1; r=mx-1;
		}
		sort(v.begin(), v.end());
		for(int i=1; i<(int)v.size(); i++)
			ret=max(ret, v[i]-v[i-1]);
		return ret;
	}
	MinMax(0, 1e18, &mn, &mx);
	ll gap=(mx-mn-1)/(n-1)+1;
	ll l=mn, r=mx, last=l, ans=gap;
	for(ll i=l; i<r; i+=gap)
	{
		MinMax(i, min(r, i+gap-1), &mn, &mx);
		if(mx==-1) continue;
		ans=max(ans, mn-last);
		last=mx;
	}
	ans=max(ans, r-last);
	return ans;
}
/*
11
5 7 8 100 130 190 200 201 203 1000 2004
*/

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:15:17: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |   while(v.size()<n)
      |         ~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 8 ms 812 KB Output is correct
17 Correct 8 ms 848 KB Output is correct
18 Correct 8 ms 816 KB Output is correct
19 Correct 9 ms 812 KB Output is correct
20 Correct 7 ms 848 KB Output is correct
21 Correct 32 ms 2220 KB Output is correct
22 Correct 32 ms 2208 KB Output is correct
23 Correct 33 ms 2204 KB Output is correct
24 Correct 35 ms 2192 KB Output is correct
25 Correct 30 ms 2200 KB Output is correct
26 Correct 33 ms 2212 KB Output is correct
27 Correct 35 ms 2208 KB Output is correct
28 Correct 31 ms 2196 KB Output is correct
29 Correct 38 ms 2164 KB Output is correct
30 Correct 28 ms 2156 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 10 ms 464 KB Output is correct
17 Correct 11 ms 512 KB Output is correct
18 Correct 13 ms 512 KB Output is correct
19 Correct 10 ms 508 KB Output is correct
20 Correct 5 ms 508 KB Output is correct
21 Correct 41 ms 1076 KB Output is correct
22 Correct 40 ms 1112 KB Output is correct
23 Correct 40 ms 1060 KB Output is correct
24 Correct 40 ms 1068 KB Output is correct
25 Correct 42 ms 1104 KB Output is correct
26 Correct 42 ms 1076 KB Output is correct
27 Correct 42 ms 1076 KB Output is correct
28 Correct 41 ms 1096 KB Output is correct
29 Correct 42 ms 1036 KB Output is correct
30 Correct 23 ms 1080 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct