1346 - Songs (贪心)】的更多相关文章

题目链接:uva 1346 - Songs 题目大意:John Doe 是一个著名的DJ,现在他有n首播放个曲, 每首歌曲有识别符key,歌曲长度l,以及播放频率q.想在John Doe 想将磁带上的歌曲重新排列,方便播放,播放所有歌曲有一个复杂度的计算∑(1≤i≤n)q[i] * ( ∑(1≤j≤i)l[j] ), 然后给出S,请输出重新排列后的第S首歌的识别码. 解题思路:为了使得复杂度越小,很明显的曲目长度小的要放前面,播放频率小的要放后面,所以每首歌增加一个k = l / q,即k越小的…
John Doe is a famous DJ and, therefore, has the problem of optimizing the placement of songs on his tapes. For a given tape and for each song on that tape John knows the length of the song and the frequency of playing that song. His problem is to rec…
题意:已知每首歌的标号,长度和播放频率,求一种播放顺序,使得最小,并且输出该播放顺序下第t首歌的标号. 分析: 1.长度越短,播放频率越大的歌排在前面,上式越小. 2.s(i)表示的是当前播放顺序下这首歌是第几个播放. #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #include<cmath> #include<iostream> #inc…
题目大意:n张唱片,每张都有长度和频率,要求题目中公式值最小.求一个排序,输出该排序下第m张CD的id. 思路:贪心,长度越长放越后面,频率越低放越后面,所以按len/p去排序即可. #include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;struct CD{ int id; double len; double p;} cd[100000]…
题意: 给定n和m,n组(a[i],b[i]),每一组a[i]可以压缩为b[i],求最少只需要压缩几个,使得m可以存下所有数据,无解输出-1 思路:按差贪心,排序 #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<iostream> #include<algorithm> #include<map> #include&l…
水题 #include<iostream> #include<algorithm> using namespace std; #define LL long long ; struct node{int x, y;}a[maxn]; bool cmp(node a, node b){ return a.x-a.y>b.x-b.y; } LL n, m, len, ans, ans1; int main(){ cin>>n>>m; ;i<n;++i…
又搞了一晚上OI,编了两道BZOJ和几道NOI题库,临走之前写两篇感想 noip越来越近了,韩大和clove爷已经开始停课虐我们了... 1029: [JSOI2007]建筑抢修 Time Limit: 4 Sec Memory Limit: 162 MB Submit: 3014 Solved: 1346 [Submit][Status][Discuss] Description 小刚在玩JSOI提供的一个称之为"建筑抢修"的电脑游戏:经过了一场激烈的战斗,T部落消灭了所有z部落的入…
A. The New Year: Meeting Friends time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, t…
题目链接: http://codeforces.com/problemset/problem/268/E E. Playlist time limit per test 1 secondmemory limit per test 256 megabytes 问题描述 Manao's friends often send him new songs. He never listens to them right away. Instead, he compiles them into a play…
C. Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a playlist consisting of nn songs. The ii-th song is characterized by two numbers titi and bibi — its length and beauty…