链接

[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. 辽宁移动宽带体验及魔百盒M101s-2刷机

    一.背景 坐标:辽宁 某城,移动宽带100M. 设备:移动赠送,华为光猫一只,魔百盒M101s-2电视盒子 一只,据安装人员说这个魔百盒是移动自己开发设计的. 二.上网体验 上网:浏览一般网站没问题. ...

  2. php把阿拉伯数字转为银行数字大写

    php把阿拉伯数字转为银行数字大写 前言:之前在做一个外贸公司的询报价系统时用到了记录关于金额的数据,一般阿拉伯数字都需要转为银行使用的大写数字,在这简单记录一下 /* * 数字金额转换成中文大写金额 ...

  3. 成功激活Win8.1专业版方法

    前两天安装了Win8.1,感觉界面效果都很简约,速度很快,很喜欢,但是不是破解版,本想将就着用,等到真正破解工具出来了再激活,但是用了两天发现系统右下角屏幕上有未激活的提示,时常弹出激活设置,看着有点 ...

  4. Gradle的介绍与安装

    Gradle简介 Gradle是一款致力于自动化构建和对多种开发语言的支持的构建工具.如果你想在任意开发平台上构建.测试.发布和部署软件,那么Gradle提供了一个非常灵活的模型,可以支持整个开发生命 ...

  5. transition: 0.2s all ease;

    /* 全部样式 0.2秒 缓动*/ transition: 0.2s all ease;

  6. P1056 排座椅

    非原创 #include<bits/stdc++.h>using namespace std;int t1[2009];int t2[2009]; int findmax(int *a){ ...

  7. jQuery的收尾

    一  后台管理布局增删改 二  常用事件 三  jQuery扩展 一  后台管理布局增删改(多种方法) <!DOCTYPE html> <!-- saved from url=(00 ...

  8. Plotagraph软件五分钟光速速成傻瓜教程

    http://bbs.dji.com/thread-144203-1-1.html 让照片变成动态的

  9. firewalld

    1.查看firewalld防火墙自带的区域名 [root@web ~]# firewall-cmd --get-zones block dmz drop external home internal ...

  10. Spring配置跨域请求

    本文主要是Spring+SpringMVC+MyBatis/MyBatis Plus框架环境,包括SpringBoot同样适用. 1.编写拦截器 package com.interceptor; im ...