Bing it UVALive
来源:互联网 发布:怎样增加淘宝信誉度 编辑:程序博客网 时间:2024/05/20 04:12
题目: 对于第n张牌,它的最大得分的bing的位置来源于两种情况:
1 上一张(得分只能递增) 2 相同值得最近位置 (可再次加分)
#include <bits/stdc++.h>using namespace std; const int N = 1e5+10; int last[N],dp[N]; int main(){int n,num; while( cin>>n ){if ( !n ) break; memset( last,0,sizeof last ); memset( dp,0,sizeof dp ); for ( int i=1; i<=n; i++ ) {scanf("%d",&num); if ( !last[num] ) dp[i] = dp[i-1];else dp[i] = max( dp[last[num]] + ( num==999? 3:1 ) , dp[i-1] ) ; last[num] = i; }cout<<dp[n]<<endl; } return 0 ; }
0 0
- Bing it UVALive
- UVALive 4764 Bing it
- Bing it UVALive
- uvalive 4764 Bing it 基础dp
- UVALive 4764 Bing it(dp)
- 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
- UVALive
- UVALive
- UVALive
- UVALive
- 4828: [Hnoi2017]大佬
- jboss7 jsp热部署
- ConcurrentHashMap总结
- ZMY
- UVALive-6694 Toy Boxes(二分)
- Bing it UVALive
- tenserflow实例之最近邻算法
- java zerocopy 原理
- Collection 和 Collections 比较
- 平均真实波幅(ATR)
- C++中STL的堆栈和序列的用法
- linux下安装oracle11g
- BZOJ 4216: Pig
- 块不换行