Codeforces 859C - 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 std; #define ll long long #define pb push_back #define mem(a,b) memset(a,b,sizeof(a))int a[55]; int dp[55]; int sum[55]; int main(){ios::sync_with_stdio(false);cin.tie(0);int n;cin>>n;for(int i=1;i<=n;i++)cin>>a[i];for(int i=n;i>=1;i--){sum[i]=sum[i+1]+a[i];dp[i]=max(sum[i+1]-dp[i+1]+a[i],dp[i+1]);}cout<<sum[1]-dp[1]<<' '<<dp[1]<<endl;return 0; }
转载于:https://www.cnblogs.com/widsom/p/8401310.html
Codeforces 859C - Pie Rules相关推荐
- CodeForces - 859C Pie Rules(dp+博弈)
题目链接:点击查看 题目大意:给出n个馅饼,现在给出一个令牌,规定持有令牌的人可以选择当前的馅饼给谁,然后下一轮令牌给没有拿到馅饼的人,如此往复,一开始鲍勃拿着令牌,问最后两人能吃到多少馅饼,两人肯定 ...
- *【CodeForces - 859C 】Pie Rules (博弈dp,时光倒流)
题干: You may have heard of the pie rule before. It states that if two people wish to fairly share a s ...
- CodeForces - 1313B Different Rules(数学+思维)
题目链接:点击查看 题目大意:一共有 n 个人,进行两轮比赛,假设第一轮比赛的名次为 x ,第二轮的名次为 y ,那么这个人的得分为 x + y ,最后的排位会按照得分的非严格升序排列,有一个人在第一 ...
- E. Stupid Submissions(思维)
滴答滴答---题目链接 E. Stupid Submissions time limit per test 1.5 s memory limit per test 256 MB input stand ...
- 模拟 Codeforces Round #297 (Div. 2) A. Vitaliy and Pie
题目传送门 1 /* 2 模拟:这就是一道模拟水题,看到标签是贪心,还以为错了呢 3 题目倒是很长:) 4 */ 5 #include <cstdio> 6 #include <al ...
- 递推水题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table
题目传送门 1 /* 2 模拟递推水题 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <cmath& ...
- Codeforces Round #349 (Div. 1) A. Reberland Linguistics 动态规划
A. Reberland Linguistics 题目连接: http://www.codeforces.com/contest/666/problem/A Description First-rat ...
- Educational Codeforces Round 13 E. Another Sith Tournament 状压dp
E. Another Sith Tournament 题目连接: http://www.codeforces.com/contest/678/problem/E Description The rul ...
- Codeforces Beta Round #1 A,B,C
A. Theatre Square time limit per test:1 second memory limit per test:256 megabytes input:standard in ...
最新文章
- 一种灵活,坚固且无凝胶的脑电图电极,可用于无创脑机接口
- 我的世界javaui材质包怎么下载_【我的世界指南】七、使用皮肤
- docker 核心概念整理
- Linux内核设计与实现学习笔记目录
- SIP与RTP综合应用5-RTP解包过程
- x230无线网卡驱动服务器版,ThinkPad X230网卡驱动
- 华为手机8.0.0怎么找到云相册_华为G9怎么找到云相册_失而复得 华为“查找手机”功能有多强大?快来了解一下......
- intent Filter
- android 升级数据库 修改表结构
- 0=iiLen 在C++中
- 拓端tecdat|matlab使用移动平均滤波器、重采样和Hampel过滤器进行信号平滑处理
- Pycharm 主题背景色的配置
- 杨志便嗔道 瑞星杀毒软件序列号
- WPS Office 2019 For Linux 8372 个人版发布
- Hyper-V虚拟机和虚拟化服务器区别
- Python——数学运算函数
- python画venn图
- 室内场馆360全景拍摄的注意事项
- android九宫格隐藏,android九宫格锁屏控件
- 计算机应用基础00018课件