InputThe first line contains the number of test cases T (T ≤ 100). Each test case begins with two positiveintegers n, t (1 ≤ n ≤ 50, 1 ≤ t ≤ 109), the number of candidate songs (BESIDES Jin Ge Jin Qu)and the time left (in seconds). The next line cont…
Jin Ge Jin Qu hao (If you smiled when you see the title, this problem is for you ^_^) For those who don’t know KTV, see: http://en.wikipedia.org/wiki/Karaoke_box There is one very popular song called Jin Ge Jin Qu(). It is a mix of 37 songs, and is e…
(If you smiled when you see the title, this problem is for you ^_^) For those who don’t know KTV, see: http://en.wikipedia.org/wiki/Karaoke_box There is one very popular song called Jin Ge Jin Qu(). It is a mix of 37 songs, and is extremely long (11…
• Don’t sing a song more than once (including Jin Ge Jin Qu). • For each song of length t, either sing it for exactly t seconds, or don’t sing it at all. • When a song is finished, always immediately start a new song. 每首歌唱一次,在一定时间类,要求唱歌数量尽量多,时间尽量长.而且…
分析可知,虽然t<109,但是总曲目时间大于t,实际上t不会超过180*n+678.此问题涉及到两个目标信息,首先要求曲目数量最多,在此基础上要求所唱的时间尽量长.可以定义 状态dp[i][j]表示前i首歌曲,恰好唱的时间为j时,所唱的最长时间,于是就是裸的01背包了. /*----UVa12563 Jin Ge Jin Qu */ #define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<vector> #in…
题目:题目链接 思路:由于t最大值其实只有180 * 50 + 678,可以直接当成01背包来做,需要考虑的量有两个,时间和歌曲数,其中歌曲优先级大于时间,于是我们将歌曲数作为背包收益,用时间作为背包容量进行dp,记录下最多歌曲数目,最后通过最多歌曲数目得出最多歌曲数目下的最长时间,利用滚动数组我们只需要开一维数组即可 AC代码: import java.util.Arrays; import java.util.Scanner; public class Main { final public…
每首只能唱一次,而且中间不能不唱歌,所以先把状态赋值为-1,以区别合法状态和非法状态,在唱歌曲目最多的条件下,离开时间应该尽量晚. 状态定义f[i][j]考虑前i首歌唱歌时间为j的最大唱歌曲目 #include<bits/stdc++.h> using namespace std; ; *maxn+; int f[maxt]; ; int main() { //freopen("in.txt","r",stdin); int T; scanf("…
Problem UVA12563-Jin Ge Jin Qu hao Accept: 642 Submit: 7638Time Limit: 3000 mSec Problem Description (If you smiled when you see the title, this problem is for you ^_^)For those who don’t know KTV, see: http://en.wikipedia.org/wiki/Karaoke_boxThere…
题意:过山车有n个区域,一个人有两个值F,D,在每个区域有两种选择: 1.睁眼: F += f[i], D += d[i] 2.闭眼: F = F , D -= K 问在D小于等于一定限度的时候最大的F. 解法: 用DP来做,如果定义dp[i][j]为前 i 个,D值为j的情况下最大的F的话,由于D值可能会增加到很大,所以是存不下的,又因为F每次最多增加20,那么1000次最多增加20000,所以开dp[1000][20000],dp[i][j]表示前 i 个,F值为j的情况下最小的D.…
Team Them Up! Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7608 Accepted: 2041 Special Judge Description Your task is to divide a number of persons into two teams, in such a way, that: everyone belongs to one of the teams; every t…
传送门 Description Hasan and Bahosain want to buy a new video game, they want to share the expenses. Hasan has a set of N coins and Bahosain has a set of M coins. The video game costs W JDs. Find the number of ways in which they can pay exactly W JDs su…
In Action Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5472 Accepted Submission(s): 1843 Problem Description Since 1945, when the first nuclear bomb was exploded by the Manhattan Project t…
Charm Bracelet Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 34532 Accepted: 15301 Description Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible fro…