【贪心】【CF1061B】 Views Matter】的更多相关文章

思路: 贪心. 实现: #include <bits/stdc++.h> using namespace std; ]; int main() { int n, m; while (cin >> n >> m) { ; i <= n; i++) cin >> a[i]; sort(a + , a + n + ); ; ], cnt = a[] - ; ; i <= n; i++) { ]) { if (cnt) { ans += a[i]; cn…
Description 给定一个只有一行的,由 \(n\) 组小正方体组成的方块,每组是由 \(a_i\) 块小正方体竖直堆叠起来的,求最多能抽掉多少块使得它的左视图和俯视图不变.方块不会掉落 Input 第一行是两个整数 \(n~,~m\),代表方块组数和另一个没什么卵用的参数. 下面一行 \(n\) 个数字,代表 \(a_i\) Output 一行一个数字代表答案 Hint \(1~\leq~n~\leq~10^5,1~\leq~a_i~\leq~10^9\) Solution 考虑因为只有…
题目链接 https://vjudge.net/problem/CodeForces-1061B 题面 Description You came to the exhibition and one exhibit has drawn your attention. It consists of nn stacks of blocks, where the ii-th stack consists of aiai blocks resting on the surface. The height…
传送门 https://www.cnblogs.com/violet-acmer/p/10005351.html 这是一道贪心题么???? 题意: 某展览馆展览一个物品,此物品有n堆,第 i 堆有a[ i ]个正方块,问最多可以去除多少个正方块,使得其俯视图与右视图的保持不变. 并且去除某正方块a下方的正方块时,是不会导致a方块下降的(无重力). 题解: 相关变量解释: int n,m; ll sum;//所有的方块 int a[maxn];//a[i] : 第i堆有a[i]个正方块 int i…
链接 [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(…
Codeforces Round #523 (Div. 2) 题目一览表 来源 考察知识点 完成时间 A Coins cf 贪心(签到题) 2018.11.23 B Views Matter cf 思维??? 2018.11.24 C Multiplicity cf dp 2018.11.27 D TV Shows cf 贪心+multiset 2018.12.2…
A. Coins Water. #include <bits/stdc++.h> using namespace std; int n, s; int main() { while (scanf("%d%d", &n, &s) != EOF) { ; ; --i) while (s >= i) { ++res; s -= i; } printf("%d\n", res); } ; } B. Views Matter Solved.…
题目链接: 传送门 Lawnmower time limit per test:2 second     memory limit per test:256 megabytes Description You have a garden consisting entirely of grass and weeds. Your garden is described by an n × m grid, with rows numbered 1 to n from top to bottom, an…
aterialized views are disk based and update periodically base upon the query definition. Views are virtual only and run the query definition each time they are accessed. Views evaluate the data in the tables underlying the view definition at the time…
D. Constants in the language of Shakespeare Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/132/problem/D Description Shakespeare is a widely known esoteric programming language in which programs look like plays by Shakespea…