Codeforces Round #568 (Div. 2) C2. Exam in BerSU (hard version)
链接:
https://codeforces.com/contest/1185/problem/C2
题意:
The only difference between easy and hard versions is constraints.
If you write a solution in Python, then prefer to send it in PyPy to speed up execution time.
A session has begun at Beland State University. Many students are taking exams.
Polygraph Poligrafovich is going to examine a group of n students. Students will take the exam one-by-one in order from 1-th to n-th. Rules of the exam are following:
The i-th student randomly chooses a ticket.
if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.
if the student finds the ticket easy, he spends exactly ti minutes to pass the exam. After it, he immediately gets a mark and goes home.
Students take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.
The duration of the whole exam for all students is M minutes (maxti≤M), so students at the end of the list have a greater possibility to run out of time to pass the exam.
For each student i, you should count the minimum possible number of students who need to fail the exam so the i-th student has enough time to pass the exam.
For each student i, find the answer independently. That is, if when finding the answer for the student i1 some student j should leave, then while finding the answer for i2 (i2>i1) the student j student does not have to go home.
思路:
c1和c2范围不同,就只写一个c2了
每次循环从100-1的数找有几个,优先用掉最大的就行,原本以为过不了hard版本。
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2e7 + 10;
const int MOD = 1e9 + 7;
int n, m, k, t;
int Num[MAXN];
int main()
{
cin >> n >> m;
int sum = 0, v, cnt;
for (int i = 1;i <= n;i++)
{
cnt = 0;
int tmp = sum;
cin >> v;
if (m - sum < v)
{
for (int j = 100;j >= 1;j--)
{
if (m - (tmp-j*Num[j]) >= v)
{
cnt += (tmp-m+v+j-1)/j;
break;
}
tmp -= j*Num[j];
cnt += Num[j];
}
}
cout << cnt << ' ' ;
Num[v]++;
sum += v;
}
cout << endl;
return 0;
}
Codeforces Round #568 (Div. 2) C2. Exam in BerSU (hard version)的更多相关文章
- Codeforces Round #568 (Div. 2) G1. Playlist for Polycarp (easy version) (状压dp)
题目:http://codeforces.com/contest/1185/problem/G1 题意:给你n给选项,每个选项有个类型和价值,让你选择一个序列,价值和为m,要求连续的不能有两个相同的类 ...
- Codeforces Round #568 (Div. 2) G2. Playlist for Polycarp (hard version)
因为不会打公式,随意就先将就一下? #include<cstdio> #include<algorithm> #include<iostream> #include ...
- Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version)(单调栈,递推)
Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version) 题意: 你是一名建筑工程师,现给出 n 幢建筑的预计建设高度,你想建成峰状, ...
- codeforces Round #568(Div.2)A B C
有点菜,只写出了三道.活不多说,上题开干. A. Ropewalkers Polycarp decided to relax on his weekend and visited to the per ...
- Codeforces Round #622 (Div. 2).C2 - Skyscrapers (hard version)
第二次写题解,请多多指教! http://codeforces.com/contest/1313/problem/C2 题目链接 不同于简单版本的暴力法,这个数据范围扩充到了五十万.所以考虑用单调栈的 ...
- Codeforces Round #622 (Div. 2)C2 Skyscrapers最大"尖"性矩形,思维||分治
题:https://codeforces.com/contest/1313/problem/C2 题意:给出n个数,分别代表第i个位置所能搭建的最大高度,问以哪一个位置的塔的高度为基准向左的每一个塔都 ...
- Codeforces Round #568 (Div. 2) 选做
A.B 略,相信大家都会做 ^_^ C. Exam in BerSU 题意 给你一个长度为 \(n\) 的序列 \(a_i\) .对于每个 \(i\in [1,N]\) 求 \([1,i-1]\) 中 ...
- Codeforces Round #555 (Div. 3) c2 d e f
c2:Increasing Subsequence (hard version) 那边小取那边,然后相等比较后面的长度 #include<bits/stdc++.h> using name ...
- Codeforces Round #555 (Div. 3) C2. Increasing Subsequence (hard version)【模拟】
一 题面 C2. Increasing Subsequence (hard version) 二 分析 需要思考清楚再写的一个题目,不能一看题目就上手,容易写错. 分以下几种情况: 1 左右两端数都小 ...
随机推荐
- GoLand远程Linux开发环境搭建
Goland 远程调试本文介绍如何从本机的goland连接远端server上的go代码进行调试 goland下载安装 建议购买正版,科学使用自行搜索. 需要安装插件,确保可以访问官网,不然配置下pro ...
- cocos2dx基础篇(22) 基本动画CCAnimation/CCAnimate
[小知识] CCSpriteFrame :精灵帧. 它是相对动画而产生的,其实就是一张纹理图片. CCAnimationFrame :动画帧. 由精灵帧与间隔帧数组成,是动画CC ...
- (转)Maven的pom.xml文件配置使用
转载:http://www.cnblogs.com/GarfieldTom/p/3707160.html <project xmlns="http://maven.apache.org ...
- Studio 3T 破解教程
亲测可用 ,且小编一直在使用 1.创建文件studio3t.bat 并将下面这段内容复制 @echo off ECHO 重置Studio 3T的使用日期...... FOR /f "toke ...
- Jetty启动报错排查org.eclipse.jetty.util.MultiException: Multiple exceptions
最近自己搭建了一个spring的项目,使用Maven做项目构建,使用JDK8,为了方便启动就使用jetty作为启动容器,但是却无意间步入了一个坑 [WARNING] Failed startup of ...
- Elasticsearch-安装、日志解读
ES-安装.日志解读 1. 准备tar包 https://www.elastic.co/cn/products/elasticsearch2. 解压 tar -zxvf elasticsearch-. ...
- 洛谷 P1472 奶牛家谱 Cow Pedigrees 题解
题面 这道题我觉得是个不错的题: 根据题意可以较清晰的发现ans只和n和k有关:(因为输入的只有这两个数啊~): 那么设f[i][j]表示前i层用了j个节点的方案数,g[i][j]表示深度小于等于i并 ...
- rust学习小记(1)
本文的学习资料来自 Rust 程序设计语言 简体中文版 推荐用idea来写rust,装好插件rust和toml即可 cargo(包管理) 可以使用 cargo build 或 cargo check ...
- window7下安装Elasticseach5.2.2
1. 安装JDK,至少1.8.0_73以上版本 java -version 2. 下载和解压缩Elasticsearch安装包,目录结构 3. 启动Elasticsearch:bin\elastics ...
- cmd打开指定目录技巧
在win的搜索栏直接打上“cmd”后回车 输入cmd 结果: