题解【Codeforces859C】Pie Rules】的更多相关文章

859C - Pie Rules 思路: dp 我们知道无论谁拿到decider token他拿不拿蛋糕都是确定的,都是使自己最优的结果. 于是 定义状态:dp[i]表示到第i个位置拿到decider token的人能使自己拿到的最大的值 初始状态:dp[n]=a[n] 目标状态:dp[1] 状态转移:dp[i]=max(dp[i+1],sum[i+1]-dp[i+1]+a[i])(sum[i]表示后缀和) 代码: #include<bits/stdc++.h> using namespace…
[题解]\(PIE\) \([POI2015]\) \([P3585]\) 逼自己每天一道模拟题 传送门:\(PIE\) \([POI2015]\) \([P3585]\) [题目描述] 一张 \(n*m\) 的方格纸,有些格子需要印上墨水,剩下的格子需要保持干净.你有一个 \(a*b\) 的印章,有些格子有墨水的.你需要判断能否用这个印章满足要求. 但印的过程中需要满足以下要求: \((1)\)印章不可以旋转. \((2)\)不能把墨水印到纸外面. \((3)\)纸上的同一个格子不可以印多次.…
题面 一道需要一定思考的 \(\text{DP}\) . 设 \(dp_i\) 表示第 \(i\) 步走的人能得到的最大分数, \(sum_i\) 表示 \(\sum_{j=i}^n a_j\) ,即 \(sum_i\) 为序列 \(\{a_i\}\) 的后缀和. 状态转移方程: \(dp_i=\max\{dp_{i+1}, sum_{i+1}-dp_{i+1}+a_i\}\) . 解释一下: \(dp_{i+1}\) 的意思是第 \(i+1\) 个决策的人将 \(a_{i+1}\) 给了对方,…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice…
https://www.luogu.org/problemnew/show/CF859C Description 有一个长度为\(n\)的序列,Alice和Bob在玩游戏.Bob先手掌握决策权. 他们从左向右扫整个序列,在任意时刻,拥有决策权的人有如下两个选择: 将当前的数加到自己的得分中,并将决策权给对方,对方将获得下一个数的决策权 将当前的数加到对方的得分中,并将决策权保留给自己,自己将获得下一个数的决策权 假定他们都使用最优策略,求他们最后分别能获得多少分 Input 第一行是一个整数\(…
[链接]h在这里写链接 [题意] 在这里写题意 [题解]     dp[i][0] 第i个位置,bob没有决策权     dp[i][1] 第i个位置,bob有决策权     dp[n][0] = 0;     dp[n][1] = a[n];     for (int i = n-1;i >= 1;i--){         dp[i][1] = max(a[i]+dp[i+1][0],dp[i+1][1]);         if (a[i] + dp[i+1][0]<dp[i+1][1]…
题意:有 nnn 个物品,每个物品有不同的价值,物品按顺序分给两个人,有一块令牌,每回合拥有令牌的人拥有物品的分配权,但是该回合未获得物品的那个人会在下回合获得令牌,开始令牌在Bob手里,两个人都采取最优的策略,问最后各能获得的最大价值是多少. 我们设状态 dp[i]dp[i]dp[i] 为轮到第 iii 个物品时拥有令牌所能获得的最大值. 如果正着进行求解会有些困难,我们不妨考虑逆着求解: 1.取当前的价值,那说明在上一回合中是不能有令牌的,即 dp[i]=sum[i+1]−dp[i+1]+v…
有一个长度为n的序列,Alice和Bob在玩游戏.Bob先手掌握决策权. 他们从左向右扫整个序列,在任意时刻,拥有决策权的人有如下两个选择: 将当前的数加到自己的得分中,并将决策权给对方,对方将获得下一个数的决策权 将当前的数加到对方的得分中,并将决策权保留给自己,自己将获得下一个数的决策权 假定他们都使用最优策略,求他们最后分别能获得多少分 Solution 考虑到无后效性,令 \(f[i][0/1]\) 表示 0/1 处理完了前 \(i\) 个数,先手和后手得分的差 转移即枚举上一次的位置…
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This…
秉承ACM团队合作的思想懒,这篇blog只有部分题解,剩余的请前往星感大神Star_Feel的blog食用(表示男神汉克斯更懒不屑于写我们分别代写了下...) C. Cloud Computing 扫描线搞一搞区间(主席树也OK啊,只是空间玄学,主席树理论空间nlogn实际上开小那么10倍8倍没什么锅啊zzzz),对于权值建立权值线段树,然后记录每个权值出现的次数以及区间权值和,然后在线段树上二分求答案即. #include<cstdio> #include<cstring> #i…
题目描述 输入格式 输出格式 输入输出样例 输入样例#1 3 3 3 4 3 3 1 24 5 10 5 1 4 2 3 4 5 6 5 4 2 输出样例#1 25.1327 3.1416 50.2655 题意简述 题目描述 有\(F+1\)个人来分\(N\)个圆形派,每个人得到的必须是一整块派,而不是几块拼在一起.而且派的面积要相同.求每个人最多得到多大面积的派(不必是圆形) 输入格式 输入的第一行为数据组数\(T\). 每组数据的第一行为两个整数\(N\)和\(F(1<=N,F<=1000…
A. Toda 2 题意:给你n个人,每个人的分数是a[i],每次可以从两个人到五个人的使得分数减一,使得最终的分数相等: 思路:假设答案为m:每个人的分数与答案m的差值为d[i],sum为d[i]的总和,max为d[i]的最大值:仅当sum-max>=max的时候才满足: 满足之后,总和为奇数,先取三个,再取两个(都是最大与次大值):偶数每次取两个即可: B. Minimum and Maximum 题意:人机交互题:给你一个数组 ,找出其中的最小值与最大值,需要在询问f(n)的次数内得到最大…
1644 免费馅饼(巴蜀oj上的编号) 题面:          SERKOI最新推出了一种叫做“免费馅饼”的游戏.         游戏在一个舞台上进行.舞台的宽度为W格,天幕的高度为H格,游戏者占一格.开始时,游戏者站在舞台的正中央,手里拿着一个托盘.          游戏开始后,从舞台天幕顶端的格子中不断出现馅饼并垂直下落.游戏者左右移动去接馅饼.游戏者每秒可以向左或右移动一格或两格,也可以站在愿地不动.          馅饼有很多种,游戏者事先根据自己的口味,对各种馅饼依次打了分.同…
http://cdn.ac.nbutoj.com/Problem/view.xhtml?id=1541 When rain, nocLyt discovered a magical phenomenon that the rainwater always flow to the low-lying place. 我以后都在题解里放一小段题目,让人更容易搜到,有没有很有想法!(咦这样好像放全部的题目更容易被搜到啊)(不过那样好像比较乱啊) [] Rainwater 时间限制: ms 内存限制: K…
G. Car Repair Shop time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Polycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the car repair s…
C. Pie or die Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem/C Description Volodya and Vlad play the following game. There are k pies at the cells of n  ×  m board. Each turn Volodya moves one pie to the neighbo…
Pie Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6320    Accepted Submission(s): 2383 Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I h…
1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富 Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 459  Solved: 268[Submit][Status] Description 最近,奶牛们热衷于把金币包在面粉里,然后把它们烤成馅饼.第i块馅饼中含有Ni(1<=Ni<=25)块金币,并且,这个数字被醒目地标记在馅饼表面. 奶牛们把所有烤好的馅饼在草地上排成了一个R行(1<=R<=100)…
Vitaliy and Pie Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 525A Description After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that si…
Pie Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 895    Accepted Submission(s): 246 Problem Description A lot of boys and girls come to our company to pie friends. After we get their informa…
题目在这里>_< 发现这场比赛在网上没有完整的题解,甚至连题目代码都没人贴出来(大概是因为题目太水了吧...).所以宝宝就来写个题解,也就当作成长记录了233333 A. Window 题意很简单,给出n组x,y,求x*y的值 #include <cstdio> #include <algorithm> using namespace std; int main() { int n; long long x,y; scanf("%d",&n)…
题目链接 Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie.…
2016 ACM/ICPC Asia Regional Qingdao Online(部分题解) 5878---I Count Two Three http://acm.hdu.edu.cn/showproblem.php?pid=5878 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1287    Accepted Submissi…
1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富 Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 498  Solved: 289[Submit][Status] Description 最近,奶牛们热衷于把金币包在面粉里,然后把它们烤成馅饼.第i块馅饼中含有Ni(1<=Ni<=25)块金币,并且,这个数字被醒目地标记在馅饼表面. 奶牛们把所有烤好的馅饼在草地上排成了一个R行(1<=R<=100)…
Cowcycles题解 Originally by Don Gillies [International readers should note that some words are puns on cows.] Having made a fortune on Playbov magazine, Hugh Heifer has moved from his original field in the country to a fashionable yard in the suburbs.…
UPD:我真不是想骗访问量TAT..一开始没注意总长度写着写着网页崩了王仓(其实中午的时候就时常开始卡了= =)....损失了2h(幸好长一点的都单独开了一篇)....吓得赶紧分成两坨....TAT.............. —————————————————————————————————————————————————————————————————————————————— 写(被虐)了整整一个月b站上usaco的金组题...然而到现在总共只写了100道上下TAT(当然是按AC人数降序排…
[CF1152F]Neko Rules the Catniverse(动态规划) 题面 CF 题解 我们先考虑一个需要扫一遍所有位置的做法. 那么状态一定是\(f[i]\)然后什么什么表示考虑到当前第\(i\)个位置的答案. 看看我们还需要记录什么,首先肯定要记录的是当前已经选了几个,所以多了一维\(j\). 然后考虑现在这个能不能选. 首先如果这个元素放在某个元素之前,后面一定是合法的,因为当前位置一定是全局的最大值,所以只需要考虑它可以放在谁之前就行了. 而限制是\(x\le y+m\),那…
Programming Contest Ranking . 题目描述 Heilongjiang Programming Contest will end successfully! And your task is programming contest ranking. The following rules rankings: 1. A problem is solved when it is accepted by the judges. 2. Teams are ranked accor…
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/A Description After a hard day Vitaly got very hungry and he wants to eat his favorite pot…
D. Follow Traffic Rules 题目连接: http://www.codeforces.com/contest/5/problem/D Description Everybody knows that the capital of Berland is connected to Bercouver (the Olympic capital) by a direct road. To improve the road's traffic capacity, there was pl…