HDU 4283 You Are the One】的更多相关文章

You Are the One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3348    Accepted Submission(s): 1524 Problem Description The TV shows such as You Are the One has been very popular. In order to m…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4283 题目大意:有一群屌丝,每个屌丝有个屌丝值,如果他第K个上场,屌丝值就为a[i]*(k-1),通过一个小黑屋(可以认为是栈)来调整,使得最后总屌丝值最小.解题思路:题目可以理解为给你一个栈,然后让你安排出栈入栈顺序,使得总的屌丝值最小,区间DP,设dp[i][j]为使区间[i,j]屌丝全部上阵的最小屌丝值之和,不考虑[i,j]外的花费,sum[i]为1~i的屌丝值前缀和.于是得到状态转移方程:d…
http://acm.hdu.edu.cn/showproblem.php?pid=4283 题意:有n个数字,不操作的情况下从左到右按顺序输出,但是可以先让前面的数字进栈,让后面的数字输出,然后栈里的数字再输出.执行完各种操作后,第i个数字输出的代价是w[i] * (i-1).问如何弄才能使得代价最小,输出. 思路:做了半个下午.好菜啊QAQ. 考虑两种情况: 1.左区间的元素先输出,然后右区间的元素再输出.这个时候方程为 dp[i][j] = dp[i][k] + dp[k+1][j] +…
题意:有一个队列,每个人有一个愤怒值a[i],如果他是第k个上场,不开心指数就为(k-1)*a[i].但是边上有一个小黑屋(其实就是个堆栈),可以一定程度上调整上场程序 思路:枚举区间和每个人第几个上场 dp[i][j]:[i,j]的最小分数 假设区间[i,j],第i个人第k个出场(1<=k<=j-i+1),如果第i个人第k个出场,则他之前有k-1个人出场:dp[i+1][i+k-1](应为枚举第i个人,所以从i+1开始) 然后后面剩的人又是一个子区间:dp[k+i][j]  当然在这之前有k…
t个数据 n个权值 1->n 可以入栈调整顺序 花费 第k个出来 w[i]*(k-1); 求花费最少 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #define MAXN 110 #define inf 100000000 int z[MAXN],sum[MAXN]; int dp[MAXN][MAXN]; int main() { int t,ca;…
You Are the One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the…
题意:给定n(n<=100)个人,每个人有个固定的屌丝值D. 起初这些人是站成一行,当第i个人第j个去面试的时候他的值是 Di*j. 要求所有人面试之后 这些值加起来是最小的. 队伍站成一行(其实就是个队列), 队列头部里的人可以到一个小黑屋子里,先进黑屋子的必须后出来(相当于一个栈). 然后队首的人可以选择进黑屋或者去面试,黑屋里的也可以选择去面试. 要求最少的Di*j 值之和. =========================================================…
标题效果: The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small hall, so it attract a lot of boys and girls. Now there are n boys enrol…
Problem Description The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small hall, so it attract a lot of boys and girls. Now there ar…
<题目链接> 题目大意: 有$n$个人排成一排要上台表演,每个人有一个屌丝值$pi$.第i个上台表演的人,他的不满意度为$(i-1)*p_i$.现在有一个类似于栈的黑屋子,你可以让某些人进入这个黑屋子.这些人要按照初始顺序来调整,对于排在最前面的人,有两种选择,让他直接上场或者先让他入栈.现在请你选择一个合理的上场顺序,使得最后总的不满意度最小. 解题分析: 因为是根据栈来调整上场顺序,所以将$p_i$大的人安排的尽可能靠前,这个贪心策略是错误的(很容易找到反例). 考虑用区间DP,dp[l]…