CF1061B Views Matter
思路:
贪心。
实现:
#include <bits/stdc++.h>
using namespace std;
int a[];
int main()
{
int n, m;
while (cin >> n >> m)
{
for (int i = ; i <= n; i++) cin >> a[i];
sort(a + , a + n + );
long long ans = ;
int maxn = a[], cnt = a[] - ;
for (int i = ; i <= n; i++)
{
if (a[i] == a[i - ])
{
if (cnt) { ans += a[i]; cnt--; }
else ans += a[i] - ;
}
else
{
cnt += a[i] - maxn - ;
ans += maxn;
maxn = a[i];
}
}
cout << ans << endl;
}
return ;
}
CF1061B Views Matter的更多相关文章
- 【贪心】【CF1061B】 Views Matter
Description 给定一个只有一行的,由 \(n\) 组小正方体组成的方块,每组是由 \(a_i\) 块小正方体竖直堆叠起来的,求最多能抽掉多少块使得它的左视图和俯视图不变.方块不会掉落 Inp ...
- 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[ ...
- B. Views Matter
链接 [http://codeforces.com/contest/1061/problem/B] 题意 问你最多去掉多少块使得从上和右看,投影图不变 分析 注意细节,尤其第一列 代码 #includ ...
- 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 ...
随机推荐
- 阻止Eclipse一直building workspace
Eclipse 一直不停 building workspace完美解决总结 一.产生这个问题的原因多种 1.自动升级 2.未正确关闭 3.maven下载lib挂起 等.. 二.解决总结 (1).解决方 ...
- node之get与post
Get获取内容: var http=require('http'), util=require('util'),//util 提供常用函数集合 url=require('url'); http.cre ...
- ubuntu 使用命令行清空回收站
sudo rm -rf ~/.local/share/Trash/*
- HDU1083(最大匹配)
Courses Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total S ...
- 【旧文章搬运】为什么win32k.sys在System进程空间无法访问
原文发表于百度空间,2010-01-02========================================================================== 玩过Sha ...
- 初学:利用mybatis-generator自动生成代码
所需的资源: mybatis-generator-core-1.3.2.jar,MySQL-connector-Java-5.1.22-bin.jar.mybatis-generator-core-1 ...
- 1.6 Hive配置metastore
一.配置 1.配置文件 #创建配置文件 [root@hadoop-senior ~]# cd /opt/modules/hive-0.13.1/conf/ [root@hadoop-senior co ...
- HTML学习笔记(四)常用标签
1.超链接 <a href="url">Link text</a> eg:<a href="http://www.w3school.com. ...
- 使用js在html文档的任意位置输出内容
<script type="text/javascript">document.write('这里是内容');</script>
- js中 call() ,apply(),bing()方法三者的用法和区别
面试中经常会被问到的,或者做笔试题的时候也会有这样的问题,所以今天专门对这个问题做个总结: 先看个例子: var age = '19' var myObj = { name:'小赖', myAge:t ...