csuoj 1390: Planting Trees
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1390
1390: Planting Trees
Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 192  Solved: 115
[Submit][Status][Web Board]
Description

Input

Output

Sample Input
6
39 38 9 35 39 20
Sample Output
42
HINT

Source
AC代码:
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std; bool cmp(int a, int b)
{
return a>b;
} int main()
{
int n, i, k, a[];
while(scanf("%d",&n)!=EOF)
{
for(i=; i<n; i++)
scanf("%d",&a[i]);
sort(a, a+n, cmp);
k=;
for(i=; i<n; i++)
{
k=max(a[i]+i+, k);
}
printf("%d\n", k+);
}
return ;
}
csuoj 1390: Planting Trees的更多相关文章
- 2019牛客暑期多校训练营(第三场)F Planting Trees 单调队列
		F Planting Trees 题目链接 https://ac.nowcoder.com/acm/contest/883/F 题目描述 The semester is finally over an ... 
- Planting Trees
		Planting Trees 给定N*N矩阵,求子矩形满足里面最大元素最小元素之差不超过M 单调队列 枚举上边界,下边界,及右边界, 用两个单调队列,一个维护最大值,一个维护最小 求左边界 #incl ... 
- 牛客多校第三场 F Planting Trees
		牛客多校第三场 F Planting Trees 题意: 求矩阵内最大值减最小值大于k的最大子矩阵的面积 题解: 矩阵压缩的技巧 因为对于我们有用的信息只有这个矩阵内的最大值和最小值 所以我们可以将一 ... 
- 牛客多校第三场F Planting Trees 单调栈
		Planting Trees 题意 给出一个矩阵,求最大矩阵面积满足该矩阵中任2元素的绝对值之差小于等于M T<1000) (n<500)但是题目明示单组(n*3)可过 分析 又是矩阵问题 ... 
- 2019年牛客多校第三场 F题Planting Trees(单调队列)
		题目链接 传送门 题意 给你一个\(n\times n\)的矩形,要你求出一个面积最大的矩形使得这个矩形内的最大值减最小值小于等于\(M\). 思路 单调队列滚动窗口. 比赛的时候我的想法是先枚举长度 ... 
- 2019牛客多校第三场 F.Planting Trees
		题目链接 题目链接 题解 题面上面很明显的提示了需要严格\(O(n^3)\)的算法. 先考虑一个过不了的做法,枚举右下角的\((x,y)\),然后二分矩形面积,枚举其中一边,则复杂度是\(O(n^3 ... 
- 2019牛客暑期多校训练营(第三场)- F Planting Trees
		题目链接:https://ac.nowcoder.com/acm/contest/883/F 题意:给定n×n的矩阵,求最大子矩阵使得子矩阵中最大值和最小值的差值<=M. 思路:先看数据大小,注 ... 
- 2019 牛客暑期多校  第三场  F  Planting Trees (单调队列+尺取)
		题目:https://ac.nowcoder.com/acm/contest/883/F 题意:求一个矩阵最大面积,这个矩阵的要求是矩阵内最小值与最大值差值<=m 思路:首先我们仔细观察范围,我 ... 
- 2019HDU多校训练第三场 Planting Trees 暴力 + 单调队列优化
		题意:有一个n * n的网格,每个网格中间有一颗树,你知道每棵树的高,你可以选择一个矩形区域把里面的树都围起来,但是矩形区域里面任意两棵树的高度差的绝对值不超过m,问这个矩形的最大面积是多少? 思路: ... 
随机推荐
- Difference Search Path
			1.Framework Search Path where to search frameworks (.framework bundles) in addition to sys ... 
- C++ 安全字符串拼接
			#include <stdio.h> #include <stdint.h> #include <stdarg.h> #if defined(__GNUC__) # ... 
- 设计模式:中介者模式(Mediator)
			定 义:用一个中介对象来封装一系列对象的交互.中介者使各个对象不需要显示地相互作用,从而耦合松散,而且可以独立的改变他们之间的交互. 结构图: Mediator类,抽象中介者类 abstract ... 
- response.setCharacterEncoding方法未定义
			代码一搬家,就报这错.之前几次稀里糊涂搞好忘记总结. 问题原因: 项目中用到Tomcat和weblogic.jar包,先引入weblogic.jar包时,HttpServletResponse下的se ... 
- [LeetCode]  Letter Combinations of a Phone Number(bfs)
			Given a digit string, return all possible letter combinations that the number could represent. A map ... 
- .NET:OrderBy和ThenBy
			.NET中OrderBy和ThenBy的语义是不同的,如:list.OrderBy(x=>x.A).OrderBy(x=>x.B),那么最终只会根据B进行排序:list.OrderBy(x ... 
- iOS面试题 02
			在面试的时候,面试官问我,“你对内存管理了解的多吗?” 我忘了当时是怎么回答的了,但是,肯定是一时没想起来怎么回答. 1.谁创建谁释放 2.autoreleasepool 3.retain,copy, ... 
- IN和exists 之间的比较
			IN和exists 之间的比较 NOT IN 和 NOT EXISTS之间的比较 
- Insert BLOB && CLOB from PL/SQL and JDBC
			For PL/SQL 1)Create Directory Where BLOB resides. create or replace directory temp as '/oradata2'; - ... 
- Installation of Theano on Windows
			http://deeplearning.net/software/theano/install_windows.html 
