[codeforces 1313C1] Skyscrapers (easy version) 问的是谷,答的是峰

Codeforces Round #622 (Div. 2)   比赛人数5752

[codeforces 1313C1] Skyscrapers (easy version)   问的是谷,答的是峰

总目录详见https://blog.csdn.net/mrcrack/article/details/103564004

在线测评地址https://codeforces.ml/contest/1313/problem/C1

Problem Lang Verdict Time Memory
C1 - Skyscrapers (easy version) GNU C++11 Accepted 31 ms 0 KB

比赛时,发现该题C1的AC率是B题的2-3倍,基本可以认为,以下算法是成熟算法。

在比赛时,也果断的放置B题,开始C1题的编码。

问的是谷,答的是峰

样例手动算法如下

Input1
5
1 2 3 2 1   没有谷
Output1
1 2 3 2 1   3是峰

Input2
3
10 6 8      6是谷

处理过程
10 6 6      10是峰   选和最大的输出,注意计算和,int要溢出
6 6 8       6是峰

Output2
10 6 6      10是峰


再造一组数据:在写这组数据的过程中,对
Also there mustn't be integers j and k such that jai

让输入的每个数据都成为峰,处理出新的数组,计算相应的和,and the total number of floors in all skyscrapers is the maximum possible.,选出最大的和。

AC代码如下

#include 
#define maxn 1010
#define LL long long
LL tot,sum;
int a[maxn],m[maxn],ans[maxn];
int min(int a,int b){
	return a=1;j--)a[j]=min(m[j],a[j+1]),sum+=a[j];//峰的左侧
		for(j=i+1;j<=n;j++)a[j]=min(m[j],a[j-1]),sum+=a[j];//峰的右侧
		if(tot

 

 

你可能感兴趣的:(codeforces)