[博弈 杂题] Codeforces 794E Round #414 E. Choosing Carrot
来源:互联网 发布:nginx 会话校验 编辑:程序博客网 时间:2024/05/21 13:34
这个题 首先我们要知道结论
If n is even, the answer is while if n ≥ 3 is odd, the answer is . (If n = 1 then the answer is obviously a1.)
为什么呢 证明看题解
然后可以动
#include<cstdio>#include<cstdlib>#include<algorithm>using namespace std;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;}inline void read(int &x){ char c=nc(),b=1; for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1; for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;}const int N=300005;int n,a[N];int odd[N],even[N];int ans[N];int main(){ freopen("t.in","r",stdin); freopen("t.out","w",stdout); read(n); for (int i=1;i<=n;i++) read(a[i]),ans[1]=max(ans[1],a[i]); for (int i=1;i<n;i++){ int len=min(n-i,i); even[len]=max(even[len],max(a[i],a[i+1])); } for (int i=2;i<n;i++){ int len=min(n-i,i-1); odd[len]=max(odd[len],min(a[i],max(a[i-1],a[i+1]))); } for (int i=n/2;i;i--) ans[i<<1]=max(ans[(i+1)<<1],even[i]); for (int i=(n-1)/2;i;i--) ans[i<<1|1]=max(ans[(i+1)<<1|1],odd[i]); for (int i=n;i;i--) printf("%d ",ans[i]); return 0;}
阅读全文
0 0
- [博弈 杂题] Codeforces 794E Round #414 E. Choosing Carrot
- CodeForces Round #417 E Solution:Nim博弈
- CODEFORCES, 265E Choosing Balls
- Codeforces Round #399 E Game of Stones 博弈
- CodeForces 817E Choosing The Commander题解
- Educational Codeforces Round 23 E. Choosing The Commander(01Trie)
- Educational Codeforces Round 23 E. Choosing The Commander (字典树)
- Educational Codeforces Round 23 817E. Choosing The Commander 字典树 位运算
- codeforces round#177 E
- Codeforces Round#260E
- [杂题] Codeforces 799E Round #413 E. Aquarium decoration
- Codeforces Round #116 E-Cubes 180E
- Codeforces Round#99 E(Div2)
- codeforces div2 round#230 E
- E. Pillars(Codeforces Round #271)
- codeforces Round #344 A~E
- codeforces Round 377 Div2 E
- Educational Codeforces Round 21E
- ubuntu16.10安装numpy, scipy, matplotlib
- 『ORACLE』 数据库suspend模式(11g)
- 科幻成真?ARM正开发可植入人类大脑的芯片
- Q&A——运行性能(一)
- 51nod1080
- [博弈 杂题] Codeforces 794E Round #414 E. Choosing Carrot
- struts2多图片上传实例
- T_UPFILE
- 每天一个 Linux 命令(40):wc命令
- 翻转二叉树
- Yarn FairSheduler使用FairSharePolicy计算Fair Share的规则、原理和代码实现
- 黑马--LINUX学习笔记(四)
- (75)蓝图基础脚本
- HTML综合入门