【链接】 我是链接,点我呀:)

【题意】

要让前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)的更多相关文章

  1. 【codeforces 534A】Exam

    [题目链接]:http://codeforces.com/contest/534/problem/A [题意] 给你n个人,要求任意两个编号相邻的人不能相邻; 让你安排座位方案,使得最多人的可以入座 ...

  2. 【Codeforces 1108E1】Array and Segments (Easy version)

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举最大值和最小值在什么地方. 显然,只要包含最小值的区间,都让他减少. 因为就算那个区间包含最大值,也无所谓,因为不会让答案变小. 但是那些 ...

  3. 【Codeforces 1118D1】Coffee and Coursework (Easy version)

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 从小到大枚举天数. 然后贪心地,从大到小分配a[i]到各个天当中. a[n]分配到第1天,a[n-1]分配到第2天,...然后a[n-x]又分 ...

  4. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  5. 【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 ...

  6. 【22.73%】【codeforces 606D】Lazy Student

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  8. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  9. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

随机推荐

  1. Eclipse中发布Maven管理的Web项目时找不到类的问题根源和解决办法(转)

    转自:http://blog.csdn.net/lvguanming/article/details/37812579?locationNum=12 写在前面的话 现在是越来越太原讨厌Eclipse这 ...

  2. eclipse配置spring4.0环境详细教程

    最近几天学习spring框架,在环境搭建过程中遇到了不少问题,网上找了不少资料都不是特别好,所以自己重新记录一下. 准备: 1.Eclipse下载,进官网,这里直接给链接了https://www.ec ...

  3. 「ZJOI2019」线段树 解题报告

    「ZJOI2019」线段树 听说有人喷这个题简单,然后我就跑去做,然后自闭感++,rp++(雾) 理性分析一波,可以发现最后形成的\(2^k\)个线段树,对应的操作的一个子集,按时间顺序作用到这颗线段 ...

  4. Linux下常用的配置文件位置

    1.别名配置文件 [root@room8pc205 ~]# vim /root/.bashrc     #此处是root用户定义的别名文件的位置,只有root用户登录可用 [root@room8pc2 ...

  5. python实现语音录入识别

    一.介绍 1.第一步录音存入本地 2.调用百度语音识别sdk 注意点:百度语音识别对声音源有要求,比特率必须是256kbps 二.代码 #安装必要库 pip install baidu-aip #百度 ...

  6. 剑指offer——丑数(c++)

    题目描述只包含质因子2.3和5的数称作丑数(UglyNumber).例如6.8都是丑数,但14不是,因为它包含质因子7,习惯上我们把1当做是第一个丑数.求按从小到大的顺序的第N个丑数. 思路:1.逐个 ...

  7. 炼数成金数据分析课程---14、Logistic回归

    炼数成金数据分析课程---14.Logistic回归 一.总结 一句话总结: 大纲+实例快速学习法 主要讲Logistic回归的原理及编程实现 1.事件的优势比(odds)是什么? 记y取1的概率是p ...

  8. Windows 安装 Anaconda3+PyCharm

    由于本人使用的是windows 10 操作系统,所以介绍在 windows 10 系统中安装 Anaconda3 的过程. 下载 Anaconda 官网下载地址:https://www.anacond ...

  9. 杂项-Conda:Conda

    ylbtech-杂项-Conda:Conda 1.返回顶部 1. Conda 是一个开源的软件包管理系统和环境管理系统,用于安装多个版本的软件包及其依赖关系,并在它们之间轻松切换.   外文名:Con ...

  10. python pip时openssl的错误

    也不知道看了哪个方法弄成这个样子的,也没办法,下面方法可用 https://blog.csdn.net/chr1341901410/article/details/80995451