【Codeforces 1185C2】Exam in BerSU (hard version)
【链接】 我是链接,点我呀:)
【题意】
要让前i个数字的和小于等于M.
问你最少要删掉前i-1个数字中的多少个数字,每个询问都是独立的。
【题解】
ti的范围很小。
所以N*MAX(TI)暴力枚举就行。
如果超过了M的话显然是优先把大的数字删掉。
【代码】
#include <iostream>
using namespace std;
const int INF = 100;
int n,M;
int rest[INF+10];
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n >> M;
for (int i = 1;i <= n;i++){
int x;
cin >> x;
rest[x]++;
int temp = 0;
for (int j = 1;j <= 100;j++) temp = temp + rest[j]*j;
int ans = 0;
if (temp>M){
for (int j = 100;temp>M && j >= 1;j--){
int need = (temp-M-1)/j + 1;
need = min(need,rest[j]);
if (j==x){
need = min(need,rest[j]-1);
}
ans+=need;
temp = temp - j*need;
}
}
cout<<ans<<' ';
}
return 0;
}
【Codeforces 1185C2】Exam in BerSU (hard version)的更多相关文章
- 【codeforces 534A】Exam
[题目链接]:http://codeforces.com/contest/534/problem/A [题意] 给你n个人,要求任意两个编号相邻的人不能相邻; 让你安排座位方案,使得最多人的可以入座 ...
- 【Codeforces 1108E1】Array and Segments (Easy version)
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举最大值和最小值在什么地方. 显然,只要包含最小值的区间,都让他减少. 因为就算那个区间包含最大值,也无所谓,因为不会让答案变小. 但是那些 ...
- 【Codeforces 1118D1】Coffee and Coursework (Easy version)
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 从小到大枚举天数. 然后贪心地,从大到小分配a[i]到各个天当中. a[n]分配到第1天,a[n-1]分配到第2天,...然后a[n-x]又分 ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 742A】Arpa’s hard exam and Mehrdad’s naive cheat
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【22.73%】【codeforces 606D】Lazy Student
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
随机推荐
- property和attribute的区别---value
从网上看到很多写关于input的value属性,写的setAttribute可以影响DOM的property的value,在实践中我发现不同现象, 在页面初始化后,用setAttribute对valu ...
- 40th 要掀桌子么 还是尬坐吧
今日学习精华: 面向对象编程里面有一句 非常经典的描述:-----通过类实例化一个对象,通过对象调方法----- 注意:对象调用的 方法 ,即 函数一定要有 参数 def ...
- node js实战:带数据库,加密的注册登录表单
demo 注册效果: 登陆效果: 数据库截图: 数据库操作 db.js //这个模块里面封装了所有对数据库的常用操作 var MongoClient = require('mongodb ...
- lua 线程
{ //https://blog.csdn.net/gulan0/article/details/50373276 }
- delphi 打印 PDevMode 说明
//PDevMode = _devicemodeW;// _devicemodeW = record// dmDeviceName: array[0..CCHDEVICENAME - 1] of Wi ...
- 【命令】GETBIT/SETBIT
我们在登陆某些博客网站或者视频网站的时候,网站往往会记录我们是否阅读了某篇文章,或者是观看了某个视频. 如果用传统的mysql数据库实现,如果用户数量多,文章和视频也多的情况下,那么则会给数据库带来很 ...
- 浏览器表单默认记忆功能input的 autocomplete="off"属性
一般情况下浏览器会有自动记录密码等的功能,但是有时候我们不需要这样的功能,下面有两种情况下关闭记忆功能有效: 1:在form中,如果有input[type=password],autocomplete ...
- error LNK2001: unresolved external symbol "public: __thiscall CWinAppEx::CWinAppEx(int)" (??0CWinApp
1.这个是网上找的别人的解决办法,本人没试过 解决办法: 网上大多说的这类似问题是解决自定义类的,可是这个连接是系统CWinAppEx,网上查了很久也没找到原因,重装了vs也没解决.后面在google ...
- eclipse创建maven项目时报错解决办法
1.Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 from any of ...
- Openstack组件部署 — Networking service_安装并配置Controller Node
目录 目录 前文列表 前提条件 网络环境 完成下面的步骤以创建数据库 创建service credentials服务凭证 创建Neutron的API Endpoints 配置自服务网络 安装网络组件 ...