Codeforces 923 B. Producing Snow】的更多相关文章

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…
题目描述: 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…
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…
题目链接: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]即不够消融的,减掉差值.…
题目链接  题意  每天有体积为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<…
传送门 维护一个堆. 每次先算出一个都不弹掉的总贡献. 然后把要弹掉的弹掉,并减去它们对应的贡献. 代码: #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…
题意: 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…
http://codeforces.com/contest/923/problem/D 题意: A-->BC , B-->AC , C-->AB , AAA-->empty 问指定串S是否能变成目标串T 发现1:B与C等价 B-->AC-->AAB-->AAAC-->C C-->AB-->AAC-->AAAB-->B 发现2:B前面的A可以消去 AB-->AAC-->AAAB-->A 新的变换: A-->BB…
http://codeforces.com/contest/923/problem/C Trie树 #include<cstdio> #include<iostream> using namespace std; #define N 300001 #define M 30 ,tr[N*M][],sum[N*M]; int a[N]; void read(int &x) { x=; char c=getchar(); while(!isdigit(c)) c=getchar(…
http://codeforces.com/contest/923/problem/A 题意: 初始有一个x0,可以选择任意一个<x0的质数p,之后得到x1为≥x0最小的p的倍数 然后再通过x1按照一样的算法得出一个x2 已知x2,问x0最小可能是多少 设f[x] 表示<x 的最大的x的质因数 那么x1 ∈ [x2-f[x2]+1,x2] 同理,可以得到x0 #include<cstdio> using namespace std; ]; #define min(x,y) ( (x…
注意二分写法... http://codeforces.com/problemset/problem/923/B #include<cstdio> #include<string.h> using namespace std; typedef long long ll; ; ll a[maxn],b[maxn]; ll sum[maxn]; ll tot[maxn]; int n; ll ans[maxn]; int flag[maxn]; void erfen(int i){ ,…
[题目链接]:http://codeforces.com/contest/768/problem/C [题意] 给你n个数字; 让你每次把这n个数字排序; 然后对奇数位的数字进行异或操作,然后对新生成的序列再重复上述操作总共k次; 问最后的序列的最小值和最大值分别是多少; [题解] 可以用计数排序来搞; 因为数字最大为1000; 所以将近O(K*1000)的复杂度; 完全可以的; 每次从小到大(0到1000(枚举数字; 然后根据该数字的个数判断该数字有几个数字要进行异或,几个数字保持原样. 然后…
题目链接:http://codeforces.com/contest/768/problem/C 题意:给出n个数,k个操作,和一个x,每次操作先排序然后对奇数位数进行xor x操作,最后问k次操作后最大值和最小值 为多少. 题解:看似是要找规律的但是只要暴力就行了.主要是a[i]的范围就只有10的3次,而且时间还有4s,直接来一个vis[i]表示 0-2048个数内取了几个,这样排序都不用了.直接for 0-2048就行.(2的10次1024,异或2的9次就是,2的11次减1 所以设最大为20…
题目链接 给一个多边形, 一个多边形外的定点, 求这个点距离多边形的最短距离和最长距离. 最长距离肯定是和某个顶点的连线, 而最短距离是和点的连线或是和某条边的连线. 对于一条边上的两个点a, b, 以及外面的定点p, 如果pab构成的三角形, <pab 或者<pba 是钝角, 那么最短距离是离点的最短距离, 否则是离边的.  离边的距离可以根据三角形面积算, 三角形面积可以用海伦公式算. #include <iostream> #include <vector> #i…
简单计算几何,只要算出圆心到多边形上的最短距离和最长距离即可 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; +; struct Point { double x,y; } p[maxn]; double a,b; int n; double GetPointDistance(Point p1, Point p2) { re…
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…
[题目链接] 点击打开链接 [算法] 前缀和 + 堆 [代码] #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll MAXN = 1e5; ll N,i,ans,sum,tmp; ll v[MAXN+],t[MAXN+]; priority_queue<ll,vector<ll>,greater<ll> > q; template <typename T…
[A]Protect Sheep 题意: 一个\(R*C\)的牧场中有一些羊和一些狼,如果狼在羊旁边就会把羊吃掉. 可以在空地上放狗,狼不能通过有狗的地方,狼的行走是四联通的. 问是否能够保护所有的羊不被狼吃掉,如果能输出方案. 题解: 判断是否有羊的旁边有狼,有的话就-1.没有的话把所有空地换成狗就好. #include<bits/stdc++.h> #define F(i,a,b) for(int i=a;i<=(b);++i) #define F2(i,a,b) for(int i…
A. Primal Sport 题意:有两个人轮流玩游戏.给出数X(i-1),轮到的人需要找到一个小于X(i-1)的素数x,然后得到Xi,Xi是x的倍数中大于等于X(i-1)的最小的数.现在已知X2,求最小的X0? 思路:根据题意,X1的取值范围为[X1-X2的最大质因子+1,X2),同理可知X0的取值范围为[X1-X1的最大质因子+1,,X1). #include<iostream> #include<cstring> #include<cstdio> #includ…
A. Protect Sheep time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus dec…
A. Protect Sheep time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus dec…
DP P2723 丑数 Humble Numbers(完成时间:2019.3.1) P2725 邮票 Stamps(完成时间:2019.3.1) P1021 邮票面值设计(完成时间:2019.3.1) P1070 道路游戏(完成时间:2019.3.2) P2558 [AHOI2002]网络传输(完成时间:2019.3.2) blog2(完成时间:2019.3.2) P2831 愤怒的小鸟(完成时间:2019.3.2) P3160 [CQOI2012]局部极小值(完成时间:2019.3.3) P1…
A. Peter and Snow Blower 题目连接: http://www.codeforces.com/contest/613/problem/A Description Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not…
A. Snow Footprints 题目连接: http://www.codeforces.com/contest/298/problem/A Description There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th blo…
地址:http://codeforces.com/contest/768/problem/C 题目: C. Jon Snow and his Favourite Number time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Jon Snow now has to fight with White Walkers. He has…
链接: https://codeforces.com/contest/1272/problem/B 题意: Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0,0) on an infinite grid. You also have the sequence of instructions of this robot. It is written as…
Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie it to so…
C - Peter and Snow Blower Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized th…
题 题意 给出原点(不是(0,0)那个原点)的坐标和一个多边形的顶点坐标,求多边形绕原点转一圈扫过的面积(每个顶点到原点距离保持不变). 分析 多边形到原点的最小距离和最大距离构成的两个圆之间的圆环就是所求面积. 判断最大距离一定在顶点上,最小距离可能在点上也可能在边上. 如果原点到一个顶点的连线和它所在的边构成钝角,那么最小距离在点上,否则最小距离就是顶点和该边构成三角形的原点所在的高,可以用海伦公式求三角形面积,然后求高. 不过我用的方法是点到直线的距离公式. 然后π用 acos(-1.0)…