[Codeforces Round #509 (Div. 2)] 解题分析

Codeforces传送门

A. Heist

题目描述

There was an electronic store heist last night.

All keyboards which were in the store yesterday were numbered in ascending order from some integer number x x x. For example, if x x x = 4 4 4 and there were 3 3 3 keyboards in the store, then the devices had indices 4 4 4 , 5 5 5 and 6 6 6 , and if x = 10 x = 10 x=10 and there were 7 7 7 of them then the keyboards had indices 10 10 10 , 11 11 11 , 12 12 12 , 13 13 13 , 14 14 14 , 15 15 15 and 16 16 16 .

After the heist, only n n n keyboards remain, and they have indices a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1,a2,,an . Calculate the minimum possible number of keyboards that have been stolen. The staff remember neither x x x nor the number of keyboards in the store before the heist.

输入输出格式

输入格式:

The first line contains single integer n n n ( 1 ≤ n ≤ 1   000 ) 1 \le n \le 1\,000) 1n1000) — the number of keyboards in the store that remained after the heist.

The second line contains n n n distinct integers a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1,a2,,an( 1 ≤ a i ≤ 1 0 9 1 \le a_i \le 10^{9} 1ai109) — the indices of the remaining keyboards. The integers a i a_i ai are given in arbitrary order and are pairwise distinct.

输出格式:

Print the minimum possible number of keyboards that have been stolen if the staff remember neither x x x nor the number of keyboards in the store before the heist.

输入输出样例

输入样例#1:
4
10 13 12 8
输出样例#1:
2
输入样例#2:
5
7 5 6 4 8
输出样例#2:
0

说明

In the first example, if x = 8 x=8 x=8 then minimum number of stolen keyboards is equal to 2 2 2 . The keyboards with indices 9 9 9 and 11 11 11 were stolen during the heist.

In the second example, if x = 4 x=4 x=4 then nothing was stolen during the heist.

解题分析

直接记录 m a x , m i n max, min max,min或者排下序就好了。 博主直接排序… 缅怀因为 m a x , m i n max,min max,min初值设成 1 0 − 7 , 1 0 7 10^-7,10^7 107,107 f s t fst fst的llppdd同学。

代码如下:

#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#define R register
#define IN inline
#define W while
#define gc getchar()
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
int dat[1005], num, ans;
int main(void)
{
	in(num);
	for (R int i = 1; i <= num; ++i) in(dat[i]);
	std::sort(dat + 1, dat + 1 + num);
	for (R int i = 2; i <= num; ++i)
	ans += dat[i] - dat[i - 1] - 1;
	printf("%d", ans);
}

B. Buying a TV Set

题目描述

Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a a a and screen height not greater than b b b . Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the screen is w w w , and the height of the screen is h h h , then the following condition should be met: w h = x y \frac{w}{h} = \frac{x}{y} hw=yx .

There are many different TV sets in the shop. Monocarp is sure that for any pair of positive integers w w w and hhthere is a TV set with screen width w w w and height h h h in the shop.

Monocarp isn’t ready to choose the exact TV set he is going to buy. Firstly he wants to determine the optimal screen resolution. He has decided to try all possible variants of screen size. But he must count the number of pairs of positive integers w w w and h h h , beforehand, such that ( w ≤ a w \le a wa) , ( h ≤ b h \le b hb) and ( w h = x y \frac{w}{h} = \frac{x}{y} hw=yx) .

In other words, Monocarp wants to determine the number of TV sets having aspect ratio x y \frac{x}{y} yx, screen width not exceeding a a a , and screen height not exceeding b b b . Two TV sets are considered different if they have different screen width or different screen height.

输入输出格式

输入格式:

The first line contains four integers a a a, b b b , x x x , y y y ( 1 ≤ a , b , x , y ≤ 1 0 18 1 \le a, b, x, y \le 10^{18} 1a,b,x,y1018 ) — the constraints on the screen width and height, and on the aspect ratio.

输出格式:

Print one integer — the number of different variants to choose TV screen width and screen height so that they meet the aforementioned constraints.

输入输出样例

输入样例#1:
17 15 5 3
输出样例#1:
3
输入样例#2:
14 16 7 22
输出样例#2:
0
输入样例#3:
4 2 6 4
输出样例#3:
1
输入样例#4:
1000000000000000000 1000000000000000000 999999866000004473 999999822000007597
输出样例#4:
1000000063

说明

In the first example, there are 3 3 3 possible variants: ( 5 , 3 ) (5, 3) (5,3) , ( 10 , 6 ) (10, 6) (10,6) , ( 15 , 9 ) (15, 9) (15,9) .

In the second example, there is no TV set meeting the constraints.

In the third example, there is only one variant: ( 3 , 2 ) (3, 2) (3,2) .

解题分析

显然我们把 x , y x,y x,y除以它们的 g c d gcd gcd a n s = m a x ( a x , b y ) ans = max(\frac{a}{x}, \frac{b}{y}) ans=max(xa,yb)就行了。

代码如下:

#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#define R register
#define IN inline
#define W while
#define gc getchar()
#define ll long long
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
ll a, b, x, y, g;
ll gcd(ll x, ll y) {return y ? gcd(y, x % y) : x;}
int main(void)
{
	in(a), in(b), in(x), in(y);
	g = gcd(x, y);
	x /= g; y /= g;
	printf("%I64d", std::min(a / x, b / y));
}

C. Coffee Break

题目描述

Recently Monocarp got a job. His working day lasts exactly mm minutes. During work, Monocarp wants to drink coffee at certain moments: there are n n n minutes a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1,a2,,an , when he is able and willing to take a coffee break (for the sake of simplicity let’s consider that each coffee break lasts exactly one minute).

However, Monocarp’s boss doesn’t like when Monocarp takes his coffee breaks too often. So for the given coffee break that is going to be on minute a i a_i ai , Monocarp must choose the day in which he will drink coffee during the said minute, so that every day at least dd minutes pass between any two coffee breaks. Monocarp also wants to take these n n n coffee breaks in a minimum possible number of working days (he doesn’t count days when he is not at work, and he doesn’t take coffee breaks on such days). Take into account that more than d d d minutes pass between the end of any working day and the start of the following working day.

For each of the n n n given minutes determine the day, during which Monocarp should take a coffee break in this minute. You have to minimize the number of days spent.

输入输出格式

输入格式:

The first line contains three integers n n n , m m m , d d d ( 1 ≤ n ≤ 2 ⋅ 1 0 5 , n ≤ m ≤ 1 0 9 , 1 ≤ d ≤ m 1 \le n \le 2\cdot10^{5}, n \le m \le 10^{9}, 1 \le d \le m 1n2105,nm109,1dm) — the number of coffee breaks Monocarp wants to have, the length of each working day, and the minimum number of minutes between any two consecutive coffee breaks.

The second line contains nn distinct integers a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1,a2,,an ( 1 ≤ a i ≤ m 1 \le a_i \le m 1aim), where a i a_i ai is some minute when Monocarp wants to have a coffee break.

输出格式:

In the first line, write the minimum number of days required to make a coffee break in each of the n n n given minutes.

In the second line, print n n n space separated integers. The i i i -th of integers should be the index of the day during which Monocarp should have a coffee break at minute a i a_i ai . Days are numbered from 1 1 1 . If there are multiple optimal solutions, you may print any of them.

输入输出样例

输入样例#1:
4 5 3
3 5 1 2
输出样例#1:
3
3 1 1 2 
输入样例#2:
10 10 1
10 5 7 4 6 3 2 1 9 8
输出样例#2:
2
2 1 1 2 2 1 2 1 1 2 

说明

In the first example, Monocarp can take two coffee breaks during the first day (during minutes 1 1 1 and 5 5 5 , 3 3 3minutes will pass between these breaks). One break during the second day (at minute 2 2 2 ), and one break during the third day (at minute 3 3 3 ).

In the second example, Monocarp can determine the day of the break as follows: if the minute when he wants to take a break is odd, then this break is on the first day, if it is even, then this break is on the second day.

解题分析

我们用 s e t set set维护时间, 每次先取最小的一个, 然后往后贪心取间隔尽量接近 d d d的时间点就好了。

注意间隔 d d d是指两个时间点之间有 d d d个时间点。

代码如下:

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <set>
#define R register
#define IN inline
#define gc getchar()
#define W while
#define MX 200050
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
int bel[MX], num, cnt, halt, lent;
struct INFO {int tim, id;} now;
IN bool operator < (const INFO &x, const INFO &y) {return x.tim < y.tim;}
IN bool operator == (const INFO &x, const INFO &y) {return x.tim == y.tim;}
std::set <INFO> st;
std::set <INFO>:: iterator it;
int main(void)
{
	int a;
	in(num), in(lent), in(halt);
	for (R int i = 1; i <= num; ++i) 
	in(a), st.insert({a, i});
	W (!st.empty())
	{
		++cnt;
		it = st.begin(); now = *it;
		bel[now.id] = cnt;
		st.erase(it);
		W (!st.empty())
		{
			it = st.lower_bound({now.tim + halt + 1, 0});
			if(it == st.end()) break;
			now = *it; bel[now.id] = cnt;
			st.erase(it);
		}
	}
	printf("%d\n", cnt);
	for (R int i = 1; i <= num; ++i) printf("%d ", bel[i]);
}

D. Glider

题目描述

A plane is flying at a constant height of h h h meters above the ground surface. Let’s consider that it is flying from the point ( − 1 0 9 , h ) (-10^9, h) (109,h) to the point ( 1 0 9 , h ) (10^9, h) (109,h) parallel with O x Ox Ox axis.

A glider is inside the plane, ready to start his flight at any moment (for the sake of simplicity let’s consider that he may start only when the plane’s coordinates are integers). After jumping from the plane, he will fly in the same direction as the plane, parallel to O x Ox Ox axis, covering a unit of distance every second. Naturally, he will also descend; thus his second coordinate will decrease by one unit every second.

There are ascending air flows on certain segments, each such segment is characterized by two numbers x 1 x_1 x1 and x 2 x_2 x2( x 1 &lt; x 2 x_1 &lt; x_2 x1<x2 ) representing its endpoints. No two segments share any common points. When the glider is inside one of such segments, he doesn’t descend, so his second coordinate stays the same each second. The glider still flies along O x Ox Ox axis, covering one unit of distance every second.

img

If the glider jumps out at 1 1 1, he will stop at 10 10 10 . Otherwise, if he jumps out at 2 2 2 , he will stop at 12 12 12 .Determine the maximum distance along O x Ox Ox axis from the point where the glider’s flight starts to the point where his flight ends if the glider can choose any integer coordinate to jump from the plane and start his flight. After touching the ground the glider stops altogether, so he cannot glide through an ascending airflow segment if his second coordinate is 0 0 0 .

输入输出格式

输入格式:

The first line contains two integers n n n and h h h ( 1 ≤ n ≤ 2 ⋅ 1 0 5 , 1 ≤ h ≤ 1 0 9 1 \le n \le 2\cdot10^{5}, 1 \le h \le 10^{9} 1n2105,1h109) — the number of ascending air flow segments and the altitude at which the plane is flying, respectively.

Each of the next n n n lines contains two integers x i 1 x_{i1} xi1 and x i 2 x_{i2} xi2 ( 1 ≤ x i 1 &lt; x i 2 ≤ 1 0 9 1 \le x_{i1} &lt; x_{i2} \le 10^{9} 1xi1<xi2109) — the endpoints of the i i i -th ascending air flow segment. No two segments intersect, and they are given in ascending order.

输出格式:

Print one integer — the maximum distance along O x Ox Ox axis that the glider can fly from the point where he jumps off the plane to the point where he lands if he can start his flight at any integer coordinate.

输入输出样例

输入样例#1:
3 4
2 5
7 9
10 11
输出样例#1:
10
输入样例#2:
5 10
5 7
11 12
16 20
25 26
30 33
输出样例#2:
18
输入样例#3:
1 1000000000
1 1000000000
输出样例#3:
1999999999

说明

In the first example if the glider can jump out at ( 2 , 4 ) (2, 4) (2,4) , then the landing point is ( 12 , 0 ) (12, 0) (12,0) , so the distance is 12 − 2 = 10 12-2 = 10 122=10 .

In the second example the glider can fly from ( 16 , 10 ) (16,10) (16,10) to ( 34 , 0 ) (34,0) (34,0) , and the distance is 34 − 16 = 18 34-16=18 3416=18 .

In the third example the glider can fly from ( − 100 , 1000000000 ) (-100,1000000000) (100,1000000000) to ( 1999999899 , 0 ) (1999999899,0) (1999999899,0) , so the distance is 1999999899 − ( − 100 ) = 1999999999 1999999899-(-100)=1999999999 1999999899(100)=1999999999 .

解题分析

贪心地想, 我们在每一段平行飞行的段的起点开始飞行不会更差, 所以我们从左到右枚举这个位置, t w o   p o i n t e r two\ pointer two pointer维护另一端的位置即可。

代码如下:

#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <set>
#include <algorithm>
#define R register
#define IN inline
#define W while
#define gc getchar()
#define MX 200050
#define ll long long
#define INF 1000000000
bool neg;
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc)
	if(c == '-') neg = true;
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
	if(neg) neg = false, x = -x;
}
struct Seg {ll from, to;} seg[MX];
ll inter[MX], ans, h;
int num;
int main(void)
{
	in(num); in(h); R int now = 1, from = 1;
	for (R int i = 1; i <= num; ++i) in(seg[i].from), in(seg[i].to);
	for (R int i = 2; i <= num; ++i) inter[i - 1] = seg[i].from - seg[i - 1].to;
	inter[num] = INF;
	for (R int i = 2; i <= num; ++i) inter[i] += inter[i - 1];
	for (from = 0; from < num; ++from)
	{
		W (inter[now] - inter[from] < h) ++now;
		ans = std::max(ans, seg[now].to - seg[from + 1].from + (h - (inter[now - 1] - inter[from])));
	}
	printf("%I64d", ans);
}

E. Tree Reconstruction

题目描述

Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from 1 1 1 to n n n . For every edge e e e of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge e e e (and only this edge) is erased from the tree.

Monocarp has given you a list of n − 1 n - 1 n1 pairs of numbers. He wants you to provide an example of a tree that will produce the said list if this tree exists. If such tree does not exist, say so.

输入输出格式

输入格式:

The first line contains one integer n n n ( 2 ≤ n ≤ 1 &ThinSpace; 000 2 \le n \le 1\,000 2n1000) — the number of vertices in the tree.

Each of the next n − 1 n-1 n1 lines contains two integers a i a_i ai and b i b_i bi each ( 1 ≤ a i &lt; b i ≤ n 1 \le a_i &lt; b_i \le n 1ai<bin ) — the maximal indices of vertices in the components formed if the i i i -th edge is removed.

输出格式:

If there is no such tree that can produce the given list of pairs, print “NO” (without quotes).

Otherwise print “YES” (without quotes) in the first line and the edges of the tree in the next n − 1 n - 1 n1 lines. Each of the last n − 1 n - 1 n1 lines should contain two integers x i x_i xi and y i y_i yi ( 1 ≤ x i , y i ≤ n 1 \le x_i, y_i \le n 1xi,yin ) — vertices connected by an edge.

Note: The numeration of edges doesn’t matter for this task. Your solution will be considered correct if your tree produces the same pairs as given in the input file (possibly reordered). That means that you can print the edges of the tree you reconstructed in any order.

输入输出样例

输入样例#1:
4
3 4
1 4
3 4
输出样例#1:
YES
1 3
3 2
2 4
输入样例#2:
3
1 3
1 3
输出样例#2:
NO
输入样例#3:
3
1 2
2 3
输出样例#3:
NO

说明

Possible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs.

img

解题分析

显然每一条边都有一个值为 n n n, 先特盘掉。

既然每个都有 n n n, 我们不妨把 n n n号点放在中间, 贪心放其他的点。 如果 i i i号点出现了 k k k次, 那么中间就有 k − 1 k-1 k1个比 i i i小的节点, 我们贪心从小向大填充就行了。

当然也可以构造链的情况, 把标号最大的点放在链的一端即可。

代码如下:

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <set>
#include <algorithm>
#define R register
#define IN inline
#define gc getchar()
#define W while
#define MX 1050
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
int cnt[MX];
bool vis[MX];
int num, ct;
std::set <int> st, avai;
struct Edge {int from, to;} edge[MX];
int main(void)
{
	in(num); int a, b;
	for (R int i = 1; i < num; ++i)
	{
		in(a), in(b);
		if(a < b) std::swap(a, b);
		if(a != num) return puts("NO"), 0;
		if(b == num) return puts("NO"), 0;
		cnt[b]++; st.insert(b); vis[b] = true;
	}
	for (R int i = 1; i <= num; ++i) if(!vis[i]) avai.insert(i);
	int now, tar, fir;
	W (!st.empty())
	{
		now = *st.begin(); st.erase(st.begin());
		if(cnt[now] == 1)
		{
			edge[++ct] = {now, num};
			continue;
		}
		fir = *avai.begin(); avai.erase(avai.begin());
		if(fir > now) return puts("NO"), 0;
		edge[++ct] = {num, fir};
		for (R int i = 2; i < cnt[now]; ++i)
		{
			tar = *avai.begin(); avai.erase(avai.begin());
			if(tar > now) return puts("NO"), 0;
			edge[++ct] = {tar, fir}, fir = tar;
		}
		edge[++ct] = {now, fir};
	}
	puts("YES");
	for (R int i = 1; i <= ct; ++i) printf("%d %d\n", edge[i].from, edge[i].to);
}

F. Ray in the tube

题目描述

You are given a tube which is reflective inside represented as two non-coinciding, but parallel to O x Ox Ox lines. Each line has some special integer points — positions of sensors on sides of the tube.

You are going to emit a laser ray in the tube. To do so, you have to choose two integer points A A A and B B B on the first and the second line respectively (coordinates can be negative): the point A A A is responsible for the position of the laser, and the point B B B — for the direction of the laser ray. The laser ray is a ray starting at A A A and directed at B B B which will reflect from the sides of the tube (it doesn’t matter if there are any sensors at a reflection point or not). A sensor will only register the ray if the ray hits exactly at the position of the sensor.

img

Examples of laser rays. Note that image contains two examples. The 3 3 3 sensors (denoted by black bold points on the tube sides) will register the blue ray but only 2 2 2 will register the red.Calculate the maximum number of sensors which can register your ray if you choose points A A A and B B B on the first and the second lines respectively.

输入输出格式

输入格式:

The first line contains two integers n n n and y 1 y_1 y1 ( 1 ≤ n ≤ 1 0 5 1 \le n \le 10^5 1n105 , 0 ≤ y 1 ≤ 1 0 9 0 \le y_1 \le 10^9 0y1109 ) — number of sensors on the first line and its y y y coordinate.

The second line contains n n n integers a 1 , a 2 , … , a n a_1, a_2, \ldots, a_n a1,a2,,an ( 0 ≤ a i ≤ 1 0 9 0 \le a_i \le 10^9 0ai109 ) — x x x coordinates of the sensors on the first line in the ascending order.

The third line contains two integers m m m and y 2 y_2 y2 ( 1 ≤ m ≤ 1 0 5 1 \le m \le 10^5 1m105 , y 1 &lt; y 2 ≤ 1 0 9 y_1 &lt; y_2 \le 10^9 y1<y2109 ) — number of sensors on the second line and its y y y coordinate.

The fourth line contains m m m integers b 1 , b 2 , … , b m b_1, b_2, \ldots, b_m b1,b2,,bm ( 0 ≤ b i ≤ 1 0 9 0 \le b_i \le 10^9 0bi109 ) — x x x coordinates of the sensors on the second line in the ascending order.

输出格式:

Print the only integer — the maximum number of sensors which can register the ray.

输入输出样例

输入样例#1:
3 1
1 5 6
1 3
3
输出样例#1:
3

说明

One of the solutions illustrated on the image by pair A 2 A_2 A2 and B 2 B_2 B2 .

解题分析

首先我们可以发现当 x B − x A x_B-x_A xBxA为奇数的时候可以用 x B − x A = 1 x_B-x_A=1 xBxA=1的情况代替, 而当 x B − x A = 2 k x^B-x^A=2^k xBxA=2k的情况不能通过其他凑出来。 所以我们枚举这个间隔, 每次统计。

但在间隔为 2 k 2^k 2k的情况下, 本质不同的起点有 2 k + 1 2^{k+1} 2k+1个, 我们怎么统计每种情况的答案? 其实很简单, 我们保存从 m i n ( x 1 , y 1 ) min(x_1,y_1) min(x1,y1) x i x_i xi y i y_i yi的距离 m o d   2 k + 1 mod\ 2^{k+1} mod 2k+1的值, 统计完后遍历 m a p map map统计答案即可。

代码如下:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <limits.h>
#include <map>
#include <set>
#define R register
#define IN inline
#define W while
#define gc getchar()
#define ll long long
#define MX 200500
bool neg;
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc)
	if(c == '-') neg = true;
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
	if(neg) neg = false, x = -x;
}
int numu, numd, up[MX], down[MX], pmin = INT_MAX, pmax = -INT_MAX, yu, yd, ans, res, pos;
std::map <ll, int> mpd, mpu;
std::map <ll, int> :: iterator it;
IN int calc(ll val)
{
	int ret = 0;
	mpd.clear(); mpu.clear(); ll jp = val << 1, sur;
	for (R int i = 1; i <= numd; ++i) mpd[(down[i] - pmin) % jp]++;
	for (R int i = 1; i <= numu; ++i) mpu[(up[i] - pmin) % jp]++;
	for (it = mpd.begin(); it != mpd.end(); it++)
	{
		sur = it -> first;
		ret = std::max(ret, it -> second + mpu[(sur + val) % jp]);
	}
	for (it = mpu.begin(); it != mpu.end(); it++)//注意可能只去上面或只取下面的情况, 所以两边都要枚举到
	{
		sur = it -> first;
		ret = std::max(ret, it -> second + mpd[(sur + val) % jp]);
	}
	return ret;
}
int main(void)
{
	in(numd); in(yd);
	for (R int i = 1; i <= numd; ++i) in(down[i]), pmin = std::min(down[i], pmin), pmax = std::max(down[i], pmax);
	in(numu); in(yu);
	for (R int i = 1; i <= numu; ++i) in(up[i]), pmin = std::min(up[i], pmin), pmax = std::max(up[i], pmax);
	int t = log2(pmax - pmin);
	if(pmax == pmin) return puts("2"), 0;
	for (R int i = 0; i <= t; ++i) ans = std::max(ans, calc(1ll << i));
	printf("%d", ans);
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值