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 ...
随机推荐
- bzoj 2600 ricehub
2600: [Ioi2011]ricehub Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 783 Solved: 417[Submit][Stat ...
- hdu 2899 Strange fuction —— 模拟退火
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2899 模拟退火: 怎么也过不了,竟然是忘了写 lst = tmp ... 还是挺容易A的. 代码如下: # ...
- ZOJ3201(树形DP)
Tree of Tree Time Limit: 1 Second Memory Limit: 32768 KB You're given a tree with weights of ea ...
- selenium_page_object
最简单的pageobject github地址:https://github.com/defnngj/selenium_page_objects
- CentOS 6.5远程连接工具x shell
安装X shell 在Window系统下远程连接Linux,x shell只是一种远程连接工具,类似工具还有CRT.VNC.putty. 以下是安装X shell的注意事项 此选项中,如不把——初始数 ...
- Subsets Forming Perfect Squares
题意: 给出n个数字,选出若干个数字,使得这些数字的乘积是一个完全平方数,问有多少种选法. 解法: 考虑异或方程组,$x_i$表示第i个数字是否选, 注意到只要保证结果中各个质因数都出现偶数次就可保证 ...
- CPython里的GIL
GIL不是Python特性,是CPython解释器特性,因为CPython有垃圾回收机制. GIL 本质是互斥锁,保护解释器安全. 保证线程安全,垃圾回收线程不会和其他线程一起运行. 多个线程不能实现 ...
- python--flask学习1
1 windows/unix得安装 http://www.pythondoc.com/flask-mega-tutorial/helloworld.html http://www.pythondoc. ...
- python 中 模块,包, 与常用模块
一 模块 模块:就是一组功能的集合体, 我们的程序可以直接导入模块来复用模块里的功能 导入方式 一般为 : import 模块名 在python中, 模块一般分为四个通用类别 1使用python编写. ...
- HDU1080 【LCS变形】
题意: 给你每种字符匹配的权值大小,给你两个串,长度小的串可以在小串里面添加空格和大串匹配,问你一个最大匹配权值. 思路: 有点类似于LCS吧,我们在求两个串的LCS的时候,不行的就扔掉了,在这里就是 ...