【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子列的个数; 然后让你输出 ...
随机推荐
- day08 python文件操作
day08 python 一.文件操作 1.文件操作的函数 open(文件名, mode=模式, encoding=字符集) 2.模式: r, w, a, r+ ...
- Dubbox服务的提供方开发
(1)创建Maven工程(WAR)dubboxdemo-service ,在pom.xml中引入依赖 <project xmlns="http://maven.apache.org/ ...
- C++中创建对象的时候加括号和不加括号的区别(转)
c++创建对象的语法有----- 1 在栈上创建 MyClass a; 2 在堆上创建加括号 MyClass *a= new MyClass(); 3 不加括号 MyClass *a = new My ...
- Ubuntu 16.04 安装docker-ce,docker-compose
Get Docker CE for Ubuntu 卸载旧版本 sudo apt-get remove docker docker-engine docker.io containerd runc 使用 ...
- 非关系型数据库MongoDB入门
本文分为以下四块简单介绍非关系型数据库MongoDB:1.MongoDB简介.2.MongoDB和关系数据库对比.3.MongoDB基本概念.4.mongo shell的使用以及对MongoDB的增删 ...
- 对于异步编程Await和Async的理解
public class AsyncInSync { /// <summary> /// 同步代码里有异步代码 /// /// /// 结果 /// Main Thread Before ...
- VC 串口通讯基本原理,讲的很是详细
目 录打开串口............................................................................................. ...
- contest-20191021
文化课读的真不开心 回来竞赛 假人 sol 根据不等式有 abs(a-b)+abs(b-c)>=abs(a-c) 那么每一个都会选. 可以发现每一段只会选在端点上(否则移到端点更优). 那么dp ...
- windows 驱动开发 DDK与WDK WDM的区别
1.首先,先从基础的东西说起,开发WINDOWS下的驱动程序,需要一个专门的开发包,如:开发JAVA程序,我们可能需要一个JDK,开发WINDOWS应用程序,我们需要WINDOWS的SDK,现在开发W ...
- Windows驱动_WFP之一WFP是什么
现在的网络安全问题,越来越受到重视,微软在VISTA以后,使用了WFP平台来代替之前XP和03中的基于包过滤的技术,比如Transport Driver Interface(TDI)过滤,Networ ...