UVA12563Jin Ge Jin Qu hao(01背包)】的更多相关文章

紫书P274 题意:输入N首歌曲和最后剩余的时间t,问在保证能唱的歌曲数目最多的情况下,时间最长:最后必唱<劲歌金曲> 所以就在最后一秒唱劲歌金曲就ok了,背包容量是t-1,来装前面的歌曲,设两个Time求时间,cnt是数量 #include <iostream> #include <cstring> #include <algorithm> #include <cstdio> using namespace std; const int MAX…
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…
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…
思路一定要清晰! /* * Author: Bingo * Created Time: 2014/12/25 3:45:35 * File Name: uva12563.cpp */ #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <…
传送门 debug了好一会,突然发现,输出错了,emmm......... 明天再写debug历程: (PS:ipad debug是真的繁琐) 题意: 题解: 尽管题干中给的 t 的范围很大,但是 t ≤ 50*180+678: int dp[maxn];///dp[i]:恰好唱i分钟时的最大曲目个数 AC代码: #include<bits/stdc++.h> #include<cstdio> #include<cstring> using namespace std;…
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. 每首歌唱一次,在一定时间类,要求唱歌数量尽量多,时间尽量长.而且…
如此水的01背包,居然让我WA了七次. 开始理解错题意了,弄反了主次关系.总曲目最多是大前提,其次才是歌曲总时间最长. 题意: 在KTV房间里还剩t秒的时间,可以从n首喜爱的歌里面选出若干首(每首歌只能唱一次且如果唱就必须唱完),然后剩下至少1秒的时间来唱那首长678秒的歌曲. 总曲目最多的前提下,尽量使歌曲总时间最长. 分析: 所给时间为t,在t-1秒内进行01背包,num[i]来记录剩余时间为 i 时能长的最多曲目,如果曲目相同还要记录最长时间. //#define LOCAL #inclu…
题目:题目链接 思路:由于t最大值其实只有180 * 50 + 678,可以直接当成01背包来做,需要考虑的量有两个,时间和歌曲数,其中歌曲优先级大于时间,于是我们将歌曲数作为背包收益,用时间作为背包容量进行dp,记录下最多歌曲数目,最后通过最多歌曲数目得出最多歌曲数目下的最长时间,利用滚动数组我们只需要开一维数组即可 AC代码: import java.util.Arrays; import java.util.Scanner; public class Main { final public…