题目链接 

题意 

每天有体积为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 1014 福尔摩斯的约会

    https://pintia.cn/problem-sets/994805260223102976/problems/994805308755394560 大侦探福尔摩斯接到一张奇怪的字条:“我们约会 ...

  2. MYSQL ROW_FORMAT=Compact

    https://dev.mysql.com/doc/refman/5.6/en/innodb-row-format-antelope.html https://docs.oracle.com/cd/E ...

  3. Enterprise Integration Patterns

    https://camel.apache.org/enterprise-integration-patterns.html 企业集成模式,各种模式算法,挺棒的. https://camel.apach ...

  4. PDF文档打印太慢怎么办

    如下图,用Adobe Acrobat打开PDF文件,然后[高级]-打勾[作为图像打印]即可

  5. multer处理post请求的代码演示

    let express = require('express'); let multer = require('multer'); let mObj = multer({dest:__dirname+ ...

  6. [转帖]JavaEE中Web服务器、Web容器、Application服务器区别及联系

    JavaEE中Web服务器.Web容器.Application服务器区别及联系 https://www.cnblogs.com/vipyoumay/p/5853694.html 在JavaEE 开发W ...

  7. 自定义Label控件

    最近开发过程中有一个需求就是修改label控件的模板,使其能够在鼠标移近的时候变成TextBox,从而方便输入,然后进行相应的修改,最终达到动态修改Label的目的,这里贴出相应的代码,并做简要的分析 ...

  8. Java微信二次开发(八)

    高级接口,先做了两个(获取用户信息和获取关注者列表) 第一步:找到包com.wtz.vo,新建类UserInfo.java package com.wtz.vo; /** * @author wang ...

  9. Python中print/format字符串格式化实例

    Python 字符串格式化使用 "字符 %格式1 %格式2 字符"%(变量1,变量2),%格式表示接受变量的类型.简单的使用例子如下 # 例:字符串格式化Name = '17jo' ...

  10. Qt ------ 覆盖eventFilter(),捕获组件事件,事件处理

    在Qt中,当一个事件发生时(例如鼠标点击或某个键盘上的按键按下),其传递顺序如图所示.从这个图可以看出,事件过滤器首先获得事件,其次才是部件的 event 函数,最后是部件的事件处理函数 事件过滤器由 ...