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 ...
随机推荐
- git解决冲突方式
Git解决冲突 安装beyond compare 4 2.配置git对比工具 #difftool 配置 git config --global diff.tool bc4 git config --g ...
- 多线程之:lock和synchronized的区别
多次思考过这个问题,都没有形成理论,今天有时间了,我把他总结出来,希望对大家有所帮助 1.ReentrantLock 拥有Synchronized相同的并发性和内存语义,此外还多了 锁投票,定时锁等候 ...
- 在浏览器上直接输入 http://www.bookEstore.com就可以访问工程问题
关于在浏览器上直接输入 http://www.bookEstore.com就可以访问工程问题 1.在tomcat/conf/server.xml文件中配置一个虚拟主机 <Host name=&q ...
- 子组件索引$refs
$refs只在组件渲染完成之后才填充,并且它是非响应式的,它仅仅作为一个直接访问访问子组件的应急方案-----应当避免的模板中或者计算属性中使用$refs
- saltstack master minion安装配置简单使用
首先先了解下saltstack是什么,为什么使用它 它与Ansible.Puppet都属于集中管理工具,由于现在企业规模的不断庞大及业务的增长,所需要管理的服务器数量增多,而且大部分机器都属于同类业务 ...
- 【旧文章搬运】NtGlobalFlags
原文发表于百度空间,2010-08-06========================================================================== - NtG ...
- HDOJ-2054
A == B ? Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- jquery的on()绑定无效的方式
on前面的元素也必须在页面加载的时候就存在于dom里面.动态的元素或者样式等,可以放在on的第二个参数里面 jQuery on()方法是官方推荐的绑定事件的一个方法.使用 on() 方法可以给将来动态 ...
- Swift3.0 数组(Array)
学习了数组的定义,创建,和元素的,增,删,改 //定义数组类型 var array1: Array<String> var array2:[String] //创建一个空数组,int类型元 ...
- MongoDb 数据修补笔记
1. 2013.08.21 KS 数据有严重问题, 缺乏数十秒数据, serialNumber 乱序