Daydreaming Stockbroker(2016 NCPC 贪心)】的更多相关文章

题目: Gina Reed, the famous stockbroker, is having a slow day at work, and between rounds of solitaire she is daydreaming. Foretelling the future is hard, but imagine if you could just go back in time and use your knowledge of stock price history in or…
A. Artwork 倒过来并查集维护即可. #include<cstdio> #include<algorithm> using namespace std; const int N=1111; int n,m,q,i,j,ce; bool black[N][N]; bool v[N*N]; int f[N*N]; int res; int ans[N*N],id[N][N],cnt; struct P{ int x,y; P(){} P(int _x,int _y){x=_x,…
题目链接:http://codeforces.com/gym/101550/attachments 总的来说就是要: 极大值卖出,极小值买入, 再加上端点时的特判. 还有就是会有连续几天股票价格相同的情况,这里就是判断的时候是严格的大于小于号的功劳了 首先手里肯定是没有股票的, 尝试买入第一天的股票, 如果下一天的股票价格低于当天的股票价格,我们就再卖出当前的所有股票来让下一天再去尝试买入股票. 除了第一天尝试买入股票的时候, 买入股票的时候应该是极小值, 我们可以一次次尝试:(如果当天的价格低…
A Artwork B Bless You Autocorrect! C Card Hand Sorting D Daydreaming Stockbroker 贪心,低买高卖,不要爆int. #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> using namespace std; typedef long long LL; const int max…
A .Artwork pro:给定N*M的白色格子,然后Q次黑棒,输出每次加黑棒后白色连通块的数量.(N,M<1e3, Q<1e4) sol:倒着离线做,并查集即可. (在线做法:https://www.cnblogs.com/asdfsag/p/10485607.html #include<bits/stdc++.h> #define ll long long #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace…
Daydreaming Stockbroker Gina Reed, the famous stockbroker, is having a slow day at work, and between rounds of solitaire she is day-dreaming. Foretelling the future is hard, but imagine if you could just go back in time and use your knowledge of stoc…
最大的位或 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description B君和G君聊天的时候想到了如下的问题.给定自然数l和r ,选取2个整数x,y满足l <= x <= y <= r ,使得x|y最大.其中|表示按位或,即C. C++. Java中的|运算.   Input 包含至多10001组测试数据.第一行有一个正整数,表示数据的组数.…
Four Operations Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 22    Accepted Submission(s): 12 Problem Description Little Ruins is a studious boy, recently he learned the four operations!Now h…
原题网址:https://open.kattis.com/problems/classrooms Classrooms The new semester is about to begin, and finding classrooms for orientation activities is always a headache. There are k classrooms on campus and n proposed activities that need to be assigne…
比赛链接:2016 ICPC Mid-Central USA Region 题目链接:Windy Path Description Consider following along the path in the figure above, starting from \((4,4)\) and moving to \((2,5)\). Then the path turns rightward toward \((1,6)\), then sharp left to \((5,0)\) and…
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1809 题目大意: 给一个长度为N(N<=105)的合法括号序列.Q(Q<=105)个询问,每次交换x,y位置上的括号后这个序列是否还合法,询问之间不影响. 题目思路: [贪心] 首先可以肯定,交换相同的括号是不会有影响的.把后面的'('和前面的')'交换也不会有影响.所以只用考虑把前面'('和后面的')'交换 而这时要满足x,y之间的所有位置i不会存在,1~i个括号中左括号数少于右…
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5922 题意: 给出 $N$ 个冰淇淋球,第 $i$ 个冰淇淋球大小为 $B_i$,现在已知冰淇淋球堆叠起来可组成一个冰淇淋. 对于上下相邻的两个冰淇淋球,只有上面的那个大小不…
E. Intellectual Inquiry 题目连接: http://www.codeforces.com/contest/655/problem/E Description After getting kicked out of her reporting job for not knowing the alphabet, Bessie has decided to attend school at the Fillet and Eggs Eater Academy. She has be…
B. Mischievous Mess Makers 题目连接: http://www.codeforces.com/contest/655/problem/B Description It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through n, are arranged so…
D. Running with Obstacles 题目连接: http://www.codeforces.com/contest/637/problem/D Description A sportsman starts from point xstart = 0 and runs to point with coordinate xfinish = m (on a straight line). Also, the sportsman can jump - to jump, he should…
题意:给你一张简单无向图(但可能不连通),再给你一个K,让你求解任意一个问题:K染色或者输出一条K长路径. 直接贪心染色,对一个点染上其相邻的点的颜色集合之中,未出现过的最小的颜色. 如果染成就染成了.如果到某个点,发现染不成,则倒着按照颜色从大到小回去,则一定恰好可以找出一条K长度的路径. #include<cstdio> #include<cstring> using namespace std; int first[1005],next[20005],v[20005],e,c…
好题 题意:给你n<=100000个数,每个数范围[0,1000],然后给你一个最大的代价T,每次最多合并k个数成为一个数,代价为k个数的总和.问最后合成1个数的总代价不大于T的最小k 题解:我们首先知道当k越大,总代价会越小,这样我们就找到了单调性,可以二分k看是否满足代价(又见最大值最小化问题).然后我们贪心寻找固定k的最小代价,可以想到每次取前k个最小的值合并成一个,再放入数组中继续这个操作,直到最后变成一个数,这样我们可以直接使用优先队列模拟. 但是直接做会超时,所以我就YY了一个优化的…
A. New Year and Hurry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last f…
http://codeforces.com/contest/725/problem/D 这题一看就是贪心的了,w - t最小的那个,肯定是优先打死. 但是一直都不会写,为什么呢,因为这个太像二分答案了,一看到这题就想到了二分答案,二分排名,二分扔掉气球...... 但是是不行的啊.因为扔掉n个,可能会变优,但是不能保证扔掉更小或者扔掉更多,那个更优呢?(可能需要三分答案?晚上回来试试) 其实这题只需要用优先队列维护. 用两个队列,que保存本来排名就比我高的那些队,优先弹出w - t最小的. 第…
camp给出的题解: 题解:贪心,先算出最小需要的长度.然后从左到右依次确定每一位.复杂度O(n)O(n) 长度为 2n2n 的串可以构造出需要 [0,1+3+...+2n-1][0,1+3+...+2n−1] 中所有的数,所以长度是单调的. 从左到右贪心着放的时候,右边的A的upper bound就是先放)再放(,这个的upper bound可以O(1)算出来 其实代码: 发现自己的贪心好弱... #include <bits/stdc++.h> using namespace std; t…
二分答案,贪心判断,洛谷上要开long long #include<iostream> #include<cstdio> using namespace std; const int N=50005; int n,m,a[N],b[N]; int read() { int r=0,f=1; char p=getchar(); while(p>'9'||p<'0') { if(p=='-') f=-1; p=getchar(); } while(p>='0'&…
题目: The gaming company Sandstorm is developing an online two player game. You have been asked to implement the ranking system. All players have a rank determining their playing strength which gets updated after every game played. There are 25 regular…
题目: Mr. Panda likes ice cream very much especially the ice cream tower. An ice cream tower consists of K ice cream balls stacking up as a tower. In order to make the tower stable, the lower ice cream ball should be at least twice as large as the ball…
题目大意: 对于给出的n个冰激凌球的大小,满足下面的球的大小是上一个的至少2倍,对于给出的k(由k的冰激凌球才能算作一个冰激凌塔),问n个冰激凌球可以最多堆出多少个高度为k的冰激凌塔 题目分析: 对于n个冰激凌球,显然我们得知可以堆出的高度为k的塔的数量在0~[n / k]之间,这里可以通过二分遍历每一种可能,初始时二分边界l==0,r==[n / k],每次取中间值mid=(l+r)/ 2,判断mid高度为k的塔能否堆出,如果可以则尝试mid为更大,否则则尝试mid为更小时,不断二分尝试mid…
分析:首先,利用贪心可知,如果要所有人的分数和最高,需要把序号大的优先放在前面.其次,对于a的前面不能为b,那么只能a在b前面了,那么就建立一条从a到b的边,并且b的入度加1.然后就是拓扑排序了.要分数最高,则把哪些入度为0的点(他们不需要有哪些人一定要在他们前面,最自由)丢进优先队列,然后就可以实现把序号大的尽量放在前面而且满足题意了. 具体见代码: #include <stdio.h> #include <algorithm> #include <string.h>…
              Wash Mr.Panda is about to engage in his favourite activity doing laundry! He’s brought L indistinguishable loads of laundry to his local laundromat, which has N washing machines and M dryers.The ith washing machine takes Wi minutes to w…
题目大意 给定一个长度为n的正整数序列,令修改一个数的代价为修改前后两个数的绝对值之差,求用最小代价将序列转换为不减序列. 其中,n满足小于500000,序列中的正整数小于10^9 题解(引自mzx神犇的题解) 本次test跪0了,尴尬 解法1(40分) 考虑dp 设到第i个数为止,序列中数全部<=j的最小代价为f[i][j] 可以推出f[i][j]=min{f[i-1][j]+|ai-j|,f[i][j-1]} 解法2(60分) 是对于第一个dp思路的优化 既然数字是固定的,可以离散化,降低空…
传送门 Description Using at most 7 matchsticks, you can draw any of the 10 digits as in the following picture: The picture shows how many sticks you need to draw each of the digits. Zaytoonah has a number that consists of N digits. She wants to move som…
题目:传送门. 题意:T组数据,每组给定一个长度n,随后给定一个长度为n的字符串,字符串只包含'('或')',随后交换其中两个位置,必须交换一次也只能交换一次,问能否构成一个合法的括号匹配,就是()()或者((()))这种的. 题解:首先n为奇数肯定是No,左括号和右括号个数不相等是No,n=2的时候如果是()也是no,因为必须交换一次,就会变成)(,所以是No.否则如果出现一个没有与其相匹配的右括号,就是右括号出现在与他匹配的左括号之前,如果这种情况出现了三次或三次以上就是No,其余是Yes.…
题目:传送门. 题意:T组数据,每组给定一个n一个m,在给定两个长度为n的数组a和b,再给定m次操作,每次给定l和r,每次可以把[l,r]的数进行任意调换位置,问能否在转换后使得a数组变成b数组. 题解:用结构体存储a数组,一共两个域,一个是值,一个是下标,这个下标指的是他最后应该在的位置即这个值在b数组中的下标.随后m次操作可以看做是对a数组的lr这个区间进行m次sort,sort是根据下标从小到大排序,这样会使得这个数向他应该在的位置偏移,就是把a数组往b数组上靠,该向左的向左去,该向右的向…