B. Views Matter
链接
[http://codeforces.com/contest/1061/problem/B]
题意
问你最多去掉多少块使得从上和右看,投影图不变
分析
注意细节,尤其第一列
代码
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100010];
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
//freopen("in.txt","r",stdin);
ll n,m,i;
while(cin>>n>>m){
for(i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
ll ma=a[n-1];
ll sum=0,j=1;
for(i=0;i<n;i++){
if(i==n-1&&j<=ma) sum+=j-1;
else if(a[i]>=j&&j<=ma&&i!=0) sum+=a[i]-1,j++;
else if(i==0&&a[i]>1) sum+=a[i]-1,j++;
else if(i==0&&a[i]==1) j++;
else if(a[i]>1) sum+=a[i]-1;
//cout<<sum<<endl;
}
cout<<sum<<endl;
}
return 0;
}
B. Views Matter的更多相关文章
- CodeForces-1061B Views Matter
题目链接 https://vjudge.net/problem/CodeForces-1061B 题面 Description You came to the exhibition and one e ...
- Codeforces Round #523 (Div. 2) B Views Matter
传送门 https://www.cnblogs.com/violet-acmer/p/10005351.html 这是一道贪心题么???? 题意: 某展览馆展览一个物品,此物品有n堆,第 i 堆有a[ ...
- 【贪心】【CF1061B】 Views Matter
Description 给定一个只有一行的,由 \(n\) 组小正方体组成的方块,每组是由 \(a_i\) 块小正方体竖直堆叠起来的,求最多能抽掉多少块使得它的左视图和俯视图不变.方块不会掉落 Inp ...
- CF1061B Views Matter
思路: 贪心. 实现: #include <bits/stdc++.h> using namespace std; ]; int main() { int n, m; while (cin ...
- Codeforces Round #523 (Div. 2)
Codeforces Round #523 (Div. 2) 题目一览表 来源 考察知识点 完成时间 A Coins cf 贪心(签到题) 2018.11.23 B Views Matter cf 思 ...
- Codeforces Round #523 (Div. 2) Solution
A. Coins Water. #include <bits/stdc++.h> using namespace std; int n, s; int main() { while (sc ...
- What is the difference between Views and Materialized Views in Oracle?
aterialized views are disk based and update periodically base upon the query definition. Views are v ...
- 【Android Training UI】创建自定义Views(Lesson 0 - 章节概览)
发表在我的独立网站http://kesenhoo.github.io/blog/2013/06/30/android-training-ui-creating-custom-views-lesson- ...
- How To Make A Swipeable Table View Cell With Actions – Without Going Nuts With Scroll Views
How To Make A Swipeable Table View Cell With Actions – Without Going Nuts With Scroll Views Ellen S ...
随机推荐
- My strength (C-A-R)
My strength: I am good at problem resolving Challenge In the first year when I come to America I pas ...
- [MapReduce_add_2] MapReduce 实现年度最高气温统计
0. 说明 编写 MapReduce 程序实现年度最高气温统计 1. 气温数据分析 气温数据样例如下: ++023450FM-+000599999V0202701N015919999999N00000 ...
- dell R740在安装完Esxi6.0U3之后出现存储器警告
最近公司新增3台戴尔R740服务器,这边分别分配内网地址0.16,0.17,0.18三个IP 然后第一天查询了ESxi6.0版本要U3A10这个版本的vmware才能兼容R740服务器 然后安装完0. ...
- cc1plus.exe: error: unrecognized command line option "-fno-keep-inline-dllexport "
在Windows环境下的控制台上,通过qmake指令编译Qt程序时,出现 cc1plus.exe: error: unrecognized command line option "-fno ...
- creo5.0安装教程(图文详解)
PTC公司最近发布了Creo 5.0正式版 ,作为最具其革命性的新一代产品设计软件,其所提供专业的二维和三维设计设计,能帮助企业和公司进行产品生命周期管理(PLM)和制定服务管理解决方案.Creo5. ...
- QT 14 线程使用
1 线程基础 QThread 是对本地平台线程的一个非常好的跨平台抽象.启动一个线程非常简单.让我们看一段代码,它产生另一个线程,该线程打印hello,然后退出. // hellothread/hel ...
- gas问题out of gas的解决
1.昨天遇见了还是以前遇见的问题,就是发现有些函数就是不能用web3调用,然后怎么弄都写不到数组上,但是今天终于将它解决了web3的学习:https://github.com/ethereum/wik ...
- Linux下rz/sz安装及使用方法
新搞的云服务器用SecureCRT不支持上传和下载,没有找到rz命令.记录一下如何安装rz/sz命令的方法. 一.工具说明 在SecureCRT这样的ssh登录软件里, 通过在Linux界面里输入rz ...
- E325: ATTENTION
vim/vi编辑器异常 E325: ATTENTION Found a swap file by the name "/usr/local/msmtp/etc/.msmtprc.swp&qu ...
- Dubbo -- 系统学习 笔记 -- 快速启动
Dubbo -- 系统学习 笔记 -- 目录 快速启动 服务提供者 服务消费者 快速启动 Dubbo采用全Spring配置方式,透明化接入应用,对应用没有任何API侵入,只需用Spring加载Dubb ...