题目链接:http://codeforces.com/contest/948/problem/C 题目大意:给定长度n(n<=1e5),第一行v[i]表示表示第i堆雪的体积,第二行t[i]表示第1~i天的雪将要消融的体积,一堆雪如果消融到体积为0则消失,求每天消融的雪的体积. 解题思路:用优先队列,第i天就将v[i]+sum[i-1]放入优先队列中,然后初始消融量ans=t[i]*q.size(),假设每堆雪都够消融,然后根据优先队列找到q.top()<=sum[i]即不够消融的,减掉差值.…
题意: n天. 每天你会堆一堆雪,体积为 v[i].每天都有一个温度 t[i] 所有之前堆过的雪在第 i 天体积都会减少 t[i] . 输出每天融化了的雪的体积. 这个题的正解我怎么想都很难理解,但是慢慢理解了. 计算一个 t[i] 的前缀和 sum. 那么到第 j 天时,设第 i 堆雪融化的体积是 V,则 V = min (sum [ j ] - sum[ i-1], v[ i ] ) 所以把 v[ i ] + sum[ i -1] 加入优先队列里,就可以只处理所有当天能化完的雪了. 若 su…
传送门 维护一个堆. 每次先算出一个都不弹掉的总贡献. 然后把要弹掉的弹掉,并减去它们对应的贡献. 代码: #include<bits/stdc++.h> #define ri register int using namespace std; typedef long long ll; inline ll read(){ ll ans=0; char ch=getchar(); while(!isdigit(ch))ch=getchar(); while(isdigit(ch))ans=(a…
题目描述: C. Producing Snow time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of i…
链接:CodeForces - 948C 题意:N天,每天生产一堆雪体积 V[i] ,每天每堆雪融化 T[i],问每天融化了多少雪. 题解:对 T 求前缀和,求每一堆雪能熬过多少天,再记录一下多余的就行了. #include <bits/stdc++.h> using namespace std; ; int N; int V[maxn], T[maxn]; long long S[maxn], E[maxn], D[maxn], X[maxn]; int main() { scanf(&qu…
time limit per test: 1 second memory limit per test: 256 megabytes Alice likes snow a lot! Unfortunately, this year’s winter is already over, and she can’t expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans t…
题目链接  题意  每天有体积为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<…
http://codeforces.com/contest/923/problem/B 题意: 有n天,每天产生一堆体积为Vi的雪,每天所有雪堆体积减少Ti 当某一堆剩余体积vi<=Ti时,体积减少vi,雪堆消失 问每天所有雪堆一共减少多少体积 fhq treap 把<=Ti的分裂出来,计算和 >Ti 的 Ti*个数 #include<cstdio> #include<iostream> #include<algorithm> using namesp…
Description 题目链接 Solution 将温度做一个前缀和,用一个优先队列依次处理一遍 思路还是很简单的 Code #include <cstdio> #include <algorithm> #include <queue> #define ll long long #define N 100010 using namespace std; priority_queue<ll,vector<ll>,greater<ll> &g…
C. Heap Operations time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Petya has recently learned data structure named "Binary heap". The heap he is now operating with allows the following…