题目链接 

题意 

每天有体积为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. PAT 1016 部分A+B

    https://pintia.cn/problem-sets/994805260223102976/problems/994805306310115328 正整数A的“D~A~(为1位整数)部分”定义 ...

  2. Ubuntu 服务器指南

    https://help.ubuntu.com/lts/serverguide/   Jabber Instant Messaging Server https://help.ubuntu.com/l ...

  3. 配置wbepack

    proxyTable:{ //反向代理 先建立连接 '/sexLady':{ target:url//请求地址 暗号:'/sexLady ' changeOrigin:true ,//类似baseUr ...

  4. CentOS 使用SMB服务 让windows能够上传文件

    1. 新增加用户 useradd zhaobsh 2. 使用 pdbedit的方式新增加用户 pdbedit -a -u zhaobsh 3. 修改smb服务 systemctl restart sm ...

  5. FICO基础知识(二)

    FI中的maser data: COA (Chart Of Account)  科目表 Account 科目 Vendor master dada  供应商主数据 Customer master da ...

  6. MES模块

    基础数据管理:产品模型.工厂模型.工艺模型 仓储管理 成本管理 绩效管理 看板管理 日志管理 设备管理:工装管理.设计器具管理.设备保养管理.设备备件管理.设备采集管理.设备点检管理.设备故障管理.设 ...

  7. appium学习记录 elements默认获取第一个元素

    封装 初始配置时候 要当做参数传入 element 发送的是一个元组 2  下标定位 当用elements进行定位时候 同时又有很多元素时候 默认获取第一个,但我们的元素是在后面时候 例如第四个 el ...

  8. codeforces1045B

    CF1045B 自己瞎鸡巴yy了一下,可知若一个数X不能被表示出来,那么X所有的表示方法都在A集合中,如a1,a2,a3······an-1,an-2中若a1+ai不能被表示出来,那么如果a1到ai是 ...

  9. hdu6165(拓扑排序+tarjan缩点)

    题意:就任意两个点能否到达: 解题思路:首先将图简化,比如假设图里有一个环,那么,这环内两个点肯定是能相互到达的,那么就不用考虑这环内的点了,很简单就想到用tarjan算法将环缩成一个点,然后就是判断 ...

  10. flask再学习-思考之怎么从数据库中查询数据在页面展示!

    看别人视频觉得很简单,要自己做蒙蔽了!这样子.NO! 1. 流程: 首先要有和数据库连接的驱动!一般有PYMySQL mysqlclient 等 使用扩展Flask-SQLAlchemy 获得orm对 ...