题目链接 

题意 

每天有体积为Vi的一堆雪,所有存在的雪每天都会融化Ti体积,求出每天具体融化的雪的体积数。

分析

对于第i天的雪堆,不妨假设其从一开始就存在,那么它的初始体积就为V[i]+T[1..i-1],在第i天则需要融化T[i]体积,若T[1....i]>=V[i]+T[1...i-1],那么这堆雪就融化完了,融化的体积为V[i]+T[1..i-1] - T[1...i-1];否则就为T[i]。用个优先队列来维护,由于默认是数值大的优先,所以实际处理中添加一个负号。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include <queue>
#include <vector>
#include<bitset>
#include<map>
#include<deque>
using namespace std;
typedef long long LL;
const int maxn = 1e5+;
const int mod = +;
typedef pair<int,int> pii;
#define X first
#define Y second
#define pb push_back
//#define mp make_pair
#define ms(a,b) memset(a,b,sizeof(a))
const int inf = 0x3f3f3f3f;
#define lson l,m,2*rt
#define rson m+1,r,2*rt+1 priority_queue<long long> que;
int V[maxn];
int main(){
int n;
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&V[i]);
}
long long sumT = ;
int T;
for(int i=;i<n;i++){
scanf("%d",&T*
que.push(-(V[i]+sumT));
long long ans=;
while(!que.empty() && que.top() >= -(sumT+T) ){
ans -= que.top()+sumT;
que.pop();
}
sumT += T;
ans += 1LL*T*que.size();
printf("%lld ",ans);
}
return ;
}

Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1) C.Producing Snow的更多相关文章

  1. Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)A. Protect Sheep

    http://codeforces.com/contest/948/problem/A   A. Protect Sheep Bob is a farmer. He has a large pastu ...

  2. Codeforces Round #470 (rated, Div. 1, based on VK Cup 2018 Round 1) 923D 947D 948E D. Picking Strings

    题: OvO http://codeforces.com/contest/947/problem/D 923D 947D 948E 解: 记要改变的串为 P1 ,记目标串为 P2  由变化规则可得: ...

  3. Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)

    A. Protect Sheep time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  4. Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)B. Primal Sport

    Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try ...

  5. Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) F 构造

    http://codeforces.com/contest/967/problem/F 题目大意: 有n个点,n*(n-1)/2条边的无向图,其中有m条路目前开启(即能走),剩下的都是关闭状态 定义: ...

  6. Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) E 贪心

    http://codeforces.com/contest/967/problem/E 题目大意: 给你一个数组a,a的长度为n 定义:b(i) = a(1)^a(2)^......^a(i), 问, ...

  7. Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) D 贪心

    http://codeforces.com/contest/967/problem/D 题目大意: 有n个服务器,标号为1~n,每个服务器有C[i]个资源.现在,有两个任务需要同时进行,令他为x1,x ...

  8. 【枚举】【二分】Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) D. Resource Distribution

    题意:有两个服务要求被满足,服务S1要求x1数量的资源,S2要求x2数量的资源.有n个服务器来提供资源,第i台能提供a[i]的资源.当你选择一定数量的服务器来为某个服务提供资源后,资源需求会等量地分担 ...

  9. 【推导】【贪心】Codeforces Round #472 (rated, Div. 2, based on VK Cup 2018 Round 2) D. Riverside Curio

    题意:海平面每天高度会变化,一个人会在每天海平面的位置刻下一道痕迹(如果当前位置没有已经刻划过的痕迹),并且记录下当天比海平面高的痕迹有多少条,记为a[i].让你最小化每天比海平面低的痕迹条数之和. ...

随机推荐

  1. HDU 2021 发工资咯:)

    http://acm.hdu.edu.cn/showproblem.php?pid=2021 Problem Description 作为杭电的老师,最盼望的日子就是每月的8号了,因为这一天是发工资的 ...

  2. Win2016以及win10 IIS10 下安装IEwebcontrol的方法

    1. 公司产品需要安装IE webcontrol控件 但是在win2016以及win10 上面安装时 因为IIS 已经升级到了IIS10 安装时会提示: 兼容解决的方法比较简单,修改注册表即可 HKE ...

  3. 【转帖】互联网加密及OpenSSL介绍和简单使用

    转帖:https://mritd.me/2016/07/02/%E4%BA%92%E8%81%94%E7%BD%91%E5%8A%A0%E5%AF%86%E5%8F%8AOpenSSL%E4%BB%8 ...

  4. bat脚本的写法

    当你每次都要输入相同的命令时,可以把这么多命令存为一个批处理,从此以后,只要运行这个批处理,就相当于打了几行.几十行命令.下面以Nginx服务的停止脚本为例写一个bat批处理文件: 1.新建nginx ...

  5. Flutter & Dart

    Flutter & Dart https://www.dartlang.org/install https://flutter.dev/ https://flutter.dev/docs/ge ...

  6. 用Delphi制作动态菜单 该文章《用Delphi制作动态菜单》

    ---恢复内容开始--- 1.首先,确定动态菜单的数据来源,即要确定动态菜单标题是来自Windows的系统注册表,还是来自一个数据库,或者是来自一个子目录,主要由程序的功能而定.这里假设主窗口名为Ma ...

  7. Dictionary CPU 100%

    昨天服务器的CPU突然100%,此服务已经运行几年了,都平安无事.既然问题出现当然要找出这个遗留多年的小概率问题.出现cpu 100% 一般就是哪里出现了无法跳出的死循环. 1.获取进程的内存信息 服 ...

  8. Gitblit 的安装使用

    1.下载gitblit,可以网上下载,也可以在下面云盘链接取 gitblit-1.8.0  下载链接:https://pan.baidu.com/s/1x7dnbyDp1FmYjMosJbGR8w 密 ...

  9. 使用TortoiseSVN创建版本库

    1. 使用TortoiseSVN创建版本库 在SVN中,为了便于创建分支和标签,我们习惯于将Repository版本库的结构布置为:/branches,/tags,/trunk.分别代表分支,标签以及 ...

  10. BZOJ1131[POI2008]Sta——树形DP

    题目描述 给出一个N个点的树,找出一个点来,以这个点为根的树时,所有点的深度之和最大 输入 给出一个数字N,代表有N个点.N<=1000000 下面N-1条边. 输出 输出你所找到的点,如果具有 ...