Codeforces Round #540 (Div. 3)--1118D1 - Coffee and Coursework (Easy version)
https://codeforces.com/contest/1118/problem/D1
能做完的天数最大不超过n,因为假如每天一杯咖啡,每杯咖啡容量大于1
首先对容量进行从大到小的排序,
sort(num.rbegin(),num.rend());
sort(num.begin(),num.end(),greater<int>());
都可以 然后遍历每一天,当第i天的时候,选出i个容量最大的分配到每一天,如果还没写完,继续选择i个最大的,但是由题意容量需要进行衰减,衰减的量为j/i(也就是把咖啡以i为单位分成了好多组,相当于减去了组号)
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
vector<int> num(n);
for(int i=;i<n;i++){
cin>>num[i];
}
sort(num.rbegin(),num.rend());
for(int i=;i<=n;i++){
int sum=;
for(int j=;j<n;j++){
sum+=max(num[j]-j/i,);
}
if(sum>=m){
cout<<i<<endl;
return ;
}
}
cout<<-<<endl;
return ;
}
Codeforces Round #540 (Div. 3)--1118D1 - Coffee and Coursework (Easy version)的更多相关文章
- Codeforces Round #540 (Div. 3) D1. Coffee and Coursework (Easy version) 【贪心】
任意门:http://codeforces.com/contest/1118/problem/D1 D1. Coffee and Coursework (Easy version) time limi ...
- Codeforces Round #540 (Div. 3)--1118D2 - Coffee and Coursework (Hard Version)
https://codeforces.com/contest/1118/problem/D2 和easy version的主要区别是,数据增加了. easy version采用的是线性查找,效率低 在 ...
- Codeforces Round #540 (Div. 3) D2. Coffee and Coursework (Hard Version) (二分,贪心)
题意:有\(n\)个数,每次可以选\(k(1\le k\le n)\)个数,并且得到\(a_1+max(0,a_2-1)+max(0,a_3-2)+...+max(0,a_k-k+1)\)的贡献,问最 ...
- Codeforces Round #521 (Div. 3) F1. Pictures with Kittens (easy version)
F1. Pictures with Kittens (easy version) 题目链接:https://codeforces.com/contest/1077/problem/F1 题意: 给出n ...
- Codeforces Round #540 (Div. 3)--1118B - Tanya and Candies(easy TL!)
Tanya has nn candies numbered from 11 to nn. The ii-th candy has the weight aiai. She plans to eat e ...
- Codeforces Round #568 (Div. 2) G1. Playlist for Polycarp (easy version) (状压dp)
题目:http://codeforces.com/contest/1185/problem/G1 题意:给你n给选项,每个选项有个类型和价值,让你选择一个序列,价值和为m,要求连续的不能有两个相同的类 ...
- Codeforces Round #575 (Div. 3) D1+D2. RGB Substring (easy version) D2. RGB Substring (hard version) (思维,枚举,前缀和)
D1. RGB Substring (easy version) time limit per test2 seconds memory limit per test256 megabytes inp ...
- Codeforces Round #540 (Div. 3) 部分题解
Codeforces Round #540 (Div. 3) 题目链接:https://codeforces.com/contest/1118 题目太多啦,解释题意都花很多时间...还有事情要做,就选 ...
- Coffee and Coursework (Easy version)
Coffee and Coursework (Easy version) time limit per test 1 second memory limit per test 256 megabyte ...
随机推荐
- Magento2 php商城在windows10上安装
magento2 下载地址:https://github.com/magento/magento2/archive/develop.zip 参考地址: 版本要求 这个magento2 要选择好php ...
- Win7自带功能,刻录光盘遇到的问题
Win7系统的可以使用系统自带有光盘刻录功能来刻录光盘. 把一张空白光盘放入刻录机,打开“计算机”窗口,双击刻录机图标,弹出“刻录光盘”对话框,选择刻录类型.这里有两个选项:一个是“类似于USB闪存驱 ...
- 利用sql的OVER()PARTITION 找到最相近的数值
前几天同事问我一个问题,能不能用sql搞定这个问题: 我这里有一个张表table1中有time1,value1,有表table2有字段time2,value2. 现在要把table2中的value2更 ...
- Nginx如何设置禁止IP访问网站
需要禁止IP访问网站.在相关的server中设置相关的限制即可.
- 最详细的Axure动态面板使用教程
1.打开[Axure]软件,在index文件上新建一个375*667大小的背景矩形并绘制页面. 具体如图所示. 2.在banner的位置上新建一个[动态面板],双击动态面板在其中新建state1.st ...
- Python压缩文件夹 tar.gz .zip
打包压缩生成 XXX.tar.gz 文件 import os import tarfile if os.path.exists(outputFileName): with tarfile.open(o ...
- swift textfiled 输入完毕 return 隐藏键盘 方法
学习swift 真是件头疼的事情 会的人少,又没有OC基础,所以 且学切珍惜吧. 在做登录的时候发现textfiled 自动调用键盘后不能隐藏?头疼 ~~~~询问了好多人 终于有人自写解答 为了方便后 ...
- 如何使用Log4j
如何使用Log4j? 1. Log4j是什么? Log4j可以帮助调试(有时候debug是发挥不了作 用的)和分析,要下载和了解更详细的内容,还是访问其官方网站吧: http://jakarta. ...
- @Html.EditorFor() 用法
@Html.EditorFor()返回一个由表达式表示的对象中的每个属性所对应的input元素,主要是针对强类型,一般这种方式用得多些a.@Html.EditorFor(mode=>mode.N ...
- Windows 平台 (UWP)应用设计
Make Your Apps Cooperate with Cross-App Communication : https://rewards.msdn.microsoft.com/Challeng ...