链接

[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. 反射的作用—>实现框架的功能

    框架与框架要解决的核心问题 我们做房子卖给用户住,用于用户自己安装门窗和空调,我做的房子就是框架,用户需要使用我的框架,把门窗插入进我提供的框架中.框架与工具类有区别,工具类被用户的类调用,而框架则是 ...

  2. python——虚拟环境之virtualenv(windows10,64位)

    1 问题 当我们拥有两个甚至多个项目A.B.C......,各个项目正常运行需求的python运行环境都不相同.而默认情况下,不管哪个项目,使用的都是全局的Python环境.上述情况,造成的问题就是, ...

  3. January 07th, 2018 Week 01st Sunday

    To remember is to disengage from the present. 铭记过去就是放弃当下. To remember the past doesn't mean we would ...

  4. BZOJ3295:[CQOI2011]动态逆序对(CDQ分治)

    Description 对于序列A,它的逆序对数定义为满足i<j,且Ai>Aj的数对(i,j)的个数.给1到n的一个排列,按照某种顺序依次删除m个元素,你的任务是在每次删除一个元素之前统计 ...

  5. springmvc 自定义拦截器实现未登录用户的拦截

    第一步:编写自定义拦截器类,该类继承HandlerInterceptorAdapter,重写preHandle方法  第二步:配置springmvc.xml文件,定义拦截器属性  登录请求的mappi ...

  6. Spring AOP失效之谜

    每天学习一点点 编程PDF电子书免费下载: http://www.shitanlife.com/code 什么是AOP1 AOP(Aspect Oriented Programming),即面向切面编 ...

  7. blinker语音控制Arduino/esp8266开关灯-滑动条使用-文本框交互

    总链接:  https://www.arduino.cn/thread-78393-1-1.html 语音控制:https://doc.blinker.app/?file=005-App%E4%BD% ...

  8. 第一行代码 3-2-2 软件也要拼脸蛋-UI界面-更强大的滚动条- 卡片

    <LinearLayout android:orientation="vertical" android:layout_width="match_parent&qu ...

  9. 转载 精进不休 .NET 4.0 (5) - C# 4.0 新特性之并行运算(Parallel) https://www.cnblogs.com/webabcd/archive/2010/06/03/1750449.html

    精进不休 .NET 4.0 (5) - C# 4.0 新特性之并行运算(Parallel)   介绍C# 4.0 的新特性之并行运算 Parallel.For - for 循环的并行运算 Parall ...

  10. nginx的server块如何支持php

    直接贴代码,备份用 server { listen ; server_name abc.com; index index.html index.htm index.php; root /var/www ...