Hackerrank Equal(这特么也是dp???)
来源:互联网 发布:软件开发界面 编辑:程序博客网 时间:2024/06/05 07:32
咸鱼的等待着军训,哎呀真的很烦,没有事情可做.
随便玩玩咯.
印度人很恶心,喜欢各种trick.
/* xzppp */#include <iostream>#include <vector>#include <cstdio>#include <string.h>#include <algorithm>#include <queue>#include <map>#include <string>using namespace std;#define FFF freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define MP make_pair#define PB push_backtypedef long long LL;typedef unsigned long long ULL;const int MAXN = 10000+17;const int MAXM = 20;const int INF = 0x7fffffff;const int MOD = 1e9+7;LL a[MAXN],dp[1000+17];int main(){ #ifndef ONLINE_JUDGE FFF #endif int t; cin>>t; while(t--) { memset(dp, 0, sizeof(dp)); LL n,mn=INF; cin>>n; for (int i = 0; i < n; ++i) { scanf("%lld",a+i); mn = min(a[i],mn); } LL h[10] = {0}; for (int i = 0; i < n; ++i) { a[i]-=mn; int temp = a[i]/5; h[5]+=temp; a[i]-=temp*5; h[a[i]]++; } dp[mn] = h[1]+h[2]+2*h[3]+2*h[4]+h[5]; LL ans = min(dp[mn],1LL*INF); LL have = h[5]; for (int i = mn-1; i > mn-10; --i) { have += h[4]; int temp = h[0]; h[0] = h[4]; h[4] = h[3]; h[3] = h[2]; h[2] = h[1]; h[1] = temp; LL zz = (h[1]+h[2]+2*h[3]+2*h[4])+have; ans = min(ans,zz); } cout<<ans<<endl; } return 0;}
阅读全文
0 0
- Hackerrank Equal(这特么也是dp???)
- HackerRank: Equal
- HackerRank--Equal Stacks
- 【HackerRank】Fair Cut(DP)
- hackerRank
- HackerRank
- HackerRank
- HackerRank
- HackerRank
- HackerRank
- HackerRank
- HackerRank Even Tree(树dp)
- hackerrank The Coin Change Problem(dp)
- 6661 Equal Sum Sets(DP)
- hdu1300(水题也是dp)
- HackerRank Medium(30) Super Six Substrings DP+数学
- hdu 3280 Equal Sum Partitions (区间dp)
- 416. Partition Equal Subset Sum (dp)
- 动态二维数组
- Shell脚本中各种括号用法
- HDU 4370 0 or 1(最短路)by Kuangbin
- php socket编程
- Linux shell
- Hackerrank Equal(这特么也是dp???)
- 计算机组成原理之机器
- Android音频驱动-ASOC之CPU DAI
- oracle的max()、full join和declare
- QStackedWidget
- 华为笔试:最高分是多少(2016)
- 快速幂
- MFC CPropertySheet 多页面切换 实例
- Java JFrame