https://codeforces.com/contest/1015/problem/C

C++版本一

简单排序

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUGusing namespace std;
typedef long long ll;
const int N=100000+10;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m;
int c[N];
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endifscanf("%d%d",&n,&m);int a,b;ll suma=0;ll sumb=0;for(int i=1;i<=n;i++){scanf("%d%d",&a,&b);c[i]=a-b;suma+=a;sumb+=b;}if(sumb>m){cout << -1 << endl;return 0;}if(suma<=m){cout << 0 << endl;return 0;}sort(c+1,c+n+1);int ans=n;for(int i=1;i<=n;i++){if(sumb+c[i]>m){ans=i;break;}else{sumb+=c[i];}}cout << n-ans+1 << endl;//cout << "Hello world!" << endl;return 0;
}

Songs Compression相关推荐

  1. cf-#501 div3 C. Songs Compression

    题目链接:http://codeforces.com/contest/1015/problem/C 就是输入n和m,m为存储空间 然后n行a和b   a大于b 每一行的a可以压缩为b的大小 求最少只需 ...

  2. CF1015C Songs Compression (#贪心)

    题目描述 Ivan has nn songs on his phone. The size of the ii -th song is a_iai​ bytes. Ivan also has a fl ...

  3. 【贪心】Songs Compression

    17暑假练习赛2 Codeforces Round #501 (Div. 3)  1015C 贪心水题,思路简单 坑点:不开long long会过不去,以后统一用long long做题 失误:考虑到了 ...

  4. CodeForces 1015 C Songs Compression

    [题目]http://codeforces.com/contest/1015/problem/C [大意]硬盘容量为21,有4首歌,前是原来大小,后是压缩大小,问最少压缩多少个能全装下. [代码] # ...

  5. Codeforces Round #501 (Div. 3)【未完结】

    2022.3.7 题单地址:https://codeforces.com/contest/1015 目录 A. Points in Segments B. Obtaining the String[模 ...

  6. 基础算法 —— 贪心算法

    [概述] 贪心算法是从问题的初始状态出发,通过若干次的贪心选择而得到的最优值的一种求解策略,即贪心策略. 简单来说,贪心策略是一种在每次决策时采取当前意义下最优策略的算法,做出的选择至少在某种约束条件 ...

  7. 只有20%的iOS程序员能看懂:详解intrinsicContentSize 及 约束优先级/content Hugging/content Compression Resistance

    在了解intrinsicContentSize之前,我们需要先了解2个概念: AutoLayout在做什么 约束优先级是什么意思. 如果不了解这两个概念,看intinsic content size没 ...

  8. Compression Helper Class using SharpZipLib

    使用 SharpZipLib 进行压缩的辅助类,简化压缩字节数组和字符串的操作. using System; using System.Text; using System.IO; using ICS ...

  9. 模型加速--CLIP-Q: Deep Network Compression Learning by In-Parallel Pruning-Quantization

    CLIP-Q: Deep Network Compression Learning by In-Parallel Pruning-Quantization CVPR2018 http://www.sf ...

最新文章

  1. Spring常见面试题及答案汇总1000道(春招+秋招+社招)
  2. Confluence 6 重构 ancestor 表
  3. 【嵌入式】Libmodbus源码分析(一)-类型和结构体
  4. java_day19_MVC和配置文件
  5. 实践剖析.NET Core如何支持Cookie滑动过期和JWT混合认证、授权
  6. 【地理信息系统GIS】教案(七章全)第一章:地理信息系统概述
  7. 【LeetCode-SQL每日一练】—— 620. 有趣的电影
  8. nhibernate连接11g数据库
  9. 苹果的困境源于优质移动应用的垮台吗?
  10. 基类和派生类的构造函数,隐式调用与显式调用
  11. mysql 5.7连接java_MACOS mysql 5.7 Navicat 可以连接 , Java 报错
  12. 怎么关闭服务器系统自动更新,自动更新怎么关闭 如何关闭window自动更新提高运行速度...
  13. [译]C++17,使用 string_view 来避免复制
  14. 借助Hugo和Academic主题在github.io建立个人网站
  15. 【web前端面试题整理07】我不理解表现与数据分离。。。
  16. 漫谈程序员系列:薪资,你是我不能言说的伤
  17. Token的组成部分
  18. django自带模块实现翻页功能
  19. Python-openpyxl之二次封装
  20. 赴美生子诚实签的五大谣言!!

热门文章

  1. 什么叫做石英表_石英表和机械表的区别是什么
  2. 需要某个字体包才能正确显示此页面_如何做设计,才能做好设计
  3. 如何处理高并发写入mysql_如何处理高并发情况下的DB插入
  4. 查linux有哪些task_Java面试手册:Linux高频考点
  5. c语言如果读不到数据就跳过,4,VS常见问题解决(一闪而过、等问题)不断更新...
  6. 标定中是什么意思_机械加工中,测头有什么作用呢?
  7. 虚拟成像技术_AI帝国将崛起,国内幻真虚拟成像技术第一家
  8. php setcookie使用变量,PHP setcookie() 函数
  9. node sqlite 插入数据_使用 Sequelize 操作 Sqlite3 数据库
  10. android java和c混合编程_C/C++在Java项目、Android和Objective-C三大平台下实现混合编程...