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 ...
随机推荐
- VS2015 无法启动 IIS Express Web 服务器 解决方案
VS2015 IIS Express 无法启动Web 解决方案 [亲测已成功] 1.我的电脑—管理—事件查看器—Windows日志—应用程序: 详细信息会提示你:[模块 DLL C:\Program ...
- python--继承关系
如果子类中定义与父类同名的方法或属性,则自动会覆盖父类对应的方法或属性. 子类完全继承父类的实例 >>> class Parent: def setName(self): print ...
- C++中的istringstream
istringstream用于执行C++风格的串流操作. 下面的示例是使用一个字符串初始化istringstream类,然后再使用>>操作符来依次输出字符串中的内容. temp_mon=& ...
- Python解析器
当我们编写Python代码时,我们得到的是一个包含Python代码的以.py为扩展名的文本文件.要运行代码,就需要Python解释器去执行.py文件. 由于整个Python语言从规范到解释器都是开源的 ...
- dispatchTouchEvent
View /** * Pass the touch screen motion event down to the target view, or this * view if it is the ...
- nodejs-stream部分
参考: https://blog.csdn.net/eeewwwddd/article/details/81042225 http://nodejs.cn/api/stream.html#stream ...
- 360极速浏览器极速模式通过hosts文件切换兼容模式bat脚本
注意:需要获得管理员权限执行,且后缀为 .bat @echo offsetlocal enabledelayedexpansionset url=被替换的域名set ip=替换的域名set strNe ...
- Spring4.2+SpringMVC+Mybatis3.4的集成(转-)
文章转自 http://blog.csdn.net/jimolangge123/article/details/49210363 首先说明一下Web.xml中配置项的执行过程: <context ...
- 617. Merge Two Binary Trees
https://www.cnblogs.com/grandyang/p/7058935.html class Solution { public: TreeNode* mergeTrees(TreeN ...
- javax.servlet.http.HttpServlet" was not found on the Java Build Path
问题解决(以maven为例): 只需在pom.xml导入对应的两个依赖即可解决该问题: <dependency> <groupId>javax.servlet.jsp</ ...