链接

[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的更多相关文章

  1. CodeForces-1061B Views Matter

    题目链接 https://vjudge.net/problem/CodeForces-1061B 题面 Description You came to the exhibition and one e ...

  2. Codeforces Round #523 (Div. 2) B Views Matter

    传送门 https://www.cnblogs.com/violet-acmer/p/10005351.html 这是一道贪心题么???? 题意: 某展览馆展览一个物品,此物品有n堆,第 i 堆有a[ ...

  3. 【贪心】【CF1061B】 Views Matter

    Description 给定一个只有一行的,由 \(n\) 组小正方体组成的方块,每组是由 \(a_i\) 块小正方体竖直堆叠起来的,求最多能抽掉多少块使得它的左视图和俯视图不变.方块不会掉落 Inp ...

  4. CF1061B Views Matter

    思路: 贪心. 实现: #include <bits/stdc++.h> using namespace std; ]; int main() { int n, m; while (cin ...

  5. Codeforces Round #523 (Div. 2)

    Codeforces Round #523 (Div. 2) 题目一览表 来源 考察知识点 完成时间 A Coins cf 贪心(签到题) 2018.11.23 B Views Matter cf 思 ...

  6. Codeforces Round #523 (Div. 2) Solution

    A. Coins Water. #include <bits/stdc++.h> using namespace std; int n, s; int main() { while (sc ...

  7. 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 ...

  8. 【Android Training UI】创建自定义Views(Lesson 0 - 章节概览)

    发表在我的独立网站http://kesenhoo.github.io/blog/2013/06/30/android-training-ui-creating-custom-views-lesson- ...

  9. 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 ...

随机推荐

  1. [Compression] Hadoop 压缩

    0. 说明 Hadoop 压缩介绍 && 压缩格式总结 && 压缩编解码器测试 1. 介绍 [文件压缩的好处] 文件压缩的好处如下: 减少存储文件所需要的磁盘空间 加速 ...

  2. July 10th, Week 29th Sunday, 2016

    Everything is good when new, but friend when old. 老朋友更醇香. When did you meet with your last friends l ...

  3. mysqldump与innobackupex备份过程你知多少

    mysqldump与innobackupex备份过程你知多少 测试库表创建(这里在同一个库下创建两个表,一个表为innodb引擎,一个为myisam引擎) root@localhost : (none ...

  4. flex布局下el-table横向滚动条失效

    如下图,是一种常见的页面结构,我们可以有很多方法实现,inline-block,float,flex等等 但是,最近项目中遇到一个怪事,左边是侧边栏导航,右边是一个数据展示table,el-table ...

  5. localStorage 知识点

    先补充下localStorage 知识点:JS对象读取形式:localStorage.name添加/修改localStorage.name = "xuanyuan"其中" ...

  6. (7)Python赋值机制

  7. 安卓开发 1配置环境 (JDK+Andriod stiuio)

    配置JDK+Andriod stiuio 所需要用到的JDK和AS 链接:https://pan.baidu.com/s/1smHCD1z密码:rxh2 1 JAVA_SDK   1.1 下载 htt ...

  8. Qt 编程指南 3 信号和槽沟通

    https://qtguide.ustclug.org/ 1 信号和槽 所谓信号槽,简单来说,就像是插销一样:一个插头和一个插座.怎么说呢?当某种事件发生之后,比如,点击了一下鼠标,或者按了某个按键, ...

  9. Spring配置文件中的那些标签意味着什么(持续更新)

    前言 在看这边博客时,如果遇到有什么不清楚的地方,可以参考我另外一边博文.Spring标签的探索,根据这边文章自己来深入源码一探究竟.这里自己只是简单记录一下各标签作用,每个人困惑不同,自然需求也不一 ...

  10. Jmeter之mysql性能测试

    Jmeter官网地址:https://jmeter.apache.org/ 作为开发人员,必要的性能测试还是需要掌握的,虽然配置druid可以比较直观获得sql的执行时间,那些表被访问的比较多等等,但 ...