【CF1015C】Songs Compression(贪心)】的更多相关文章

题意: 给定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…
题目链接: E. Table Compression time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Little Petya is now fond of data compression algorithms. He has already studied gz, bz, zip algorithms and many o…
题意:已知每首歌的标号,长度和播放频率,求一种播放顺序,使得最小,并且输出该播放顺序下第t首歌的标号. 分析: 1.长度越短,播放频率越大的歌排在前面,上式越小. 2.s(i)表示的是当前播放顺序下这首歌是第几个播放. #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #include<cmath> #include<iostream> #inc…
感觉自己有点强迫症  不都写出来就找理由不写题解 http://codeforces.com/contest/1015   题目链接 A. Points in Segments 题目意思  n个线段 去覆盖1-m 中的点 问你没有覆盖的点的个数和位置 这个数据很小,可以直接暴力查找 思考:如果n<1e6, m<=1e8 呢? #include<bits/stdc++.h> #define int long long #define MAX(a,b,c) max(a,max(b,c)…
C. Songs Compression time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ivan has nn songs on his phone. The size of the ii-th song is aiai bytes. Ivan also has a flash drive which can hold at…
A - Points in Segments 题意:implement #include<bits/stdc++.h> using namespace std; typedef long long ll; bool vis[105]; int ans[105], atop; void test_case() { int n, m; scanf("%d%d", &n, &m); while(n--) { int u, v; scanf("%d%d&q…
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…
C. Compression and Expansion 题面 一个合法的表单由横向 N N N 行数字链,纵向一层或多层数字链组成,第 k k k 层的数字链(可以想象为前面打了 k k k 个制表符 )由 k k k 个数字组成,如 k = 3 : 1.1.1 , 1.1.2 , 1.2.1 , ⋯ k=3:1.1.1,1.1.2,1.2.1,\cdots k=3:1.1.1,1.1.2,1.2.1,⋯, k = 1 : 1 , 2 , 3 , ⋯ k=1:1,2,3,\cdots k=1:…
题目链接: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越小的…