UVALive 4764 Bing it
来源:互联网 发布:网络彩票赌博怎么举报 编辑:程序博客网 时间:2024/05/29 16:31
题目链接:点击打开链接
一道水题dp
#include<bits/stdc++.h>using namespace std;int dp[100010];int num[100010];int main(){//freopen("in.txt","r",stdin);int n;while(cin>>n){if(!n) break;memset(dp,0,sizeof(dp));memset(num,-1,sizeof(num));for(int i=1;i<=n;i++){int x;scanf("%d",&x);if(num[x]!=-1){if(x==999)dp[i]=max(dp[i-1],dp[num[x]]+3);elsedp[i]=max(dp[i-1],dp[num[x]]+1);}else dp[i]=dp[i-1];num[x]=i;}cout<<dp[n]<<endl;}}
阅读全文
0 0
- UVALive 4764 Bing it
- uvalive 4764 Bing it 基础dp
- UVALive 4764 Bing it(dp)
- Bing it UVALive
- Bing it UVALive
- Bing it
- Bing It On Kattis
- Bing It On (Kattis
- Bing it(动态规划)dp
- BING
- BING
- UVALive 5903 Piece it together
- UVALive 5063 Just Sum It
- UVALive 6571 It Can Be Arranged
- DP->UVALive 4764
- UVALive
- UVALive
- UVALive
- [Noip2016]换教室 解题报告
- 【Linux学习笔记】25:用户自定义变量
- NYOJ 2356 哈希计划(模拟)
- HUD-1002(大位数加法)
- jeecms系统使用介绍
- UVALive 4764 Bing it
- ConstraintLayout can not resolve symbol 'parent'
- 数学建模(7)——蒙特卡罗算法(Monte Carlo)
- linux-mysql-5.7.18-安装步骤
- 【MySQL】批量数据循环插入
- 通过Uri跳转Activity(当然对于WebView中的网页同样适用)
- 线段树模板
- 懒汉式单利同步链接jdbc数据库
- Mybatis 简介