Tasks

It's too late now, but you still have too much work to do. There are nn tasks on your list. The ii-th task costs you t_iti​seconds. You want to go to bed TT seconds later. During the TT seconds, you can choose some tasks to do in order to finish as many tasks as possible.

Input

Each test file contains a single test case. In each test file:

There are only two lines. The first line contains two positive integers n ( n \le 100 )n(n≤100) and T ( T \le 6000 )T(T≤6000). The second line contains nn positive integers t_1t1​, t_2, \cdots , t_n ( t_i \le 100 )t2​,⋯,tn​(ti​≤100).

Output

A number representing how many tasks can you finish before going to bed if you make the optimal decision.

样例输入复制

5 10
8 3 4 2 1

样例输出复制

4

代码:

 //A-签到
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+; int a[maxn]; int main()
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
}
sort(a+,a++n);
int cnt=,num=;
for(int i=;i<=n;i++){
if(cnt>=k){
printf("%d\n",num);
return ;
}
if(cnt+a[i]<=k){
cnt+=a[i];num++;
}
}
printf("%d\n",num);
}

计蒜客 39268.Tasks-签到 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest A.) 2019ICPC西安邀请赛现场赛重现赛的更多相关文章

  1. 计蒜客 39272.Tree-树链剖分(点权)+带修改区间异或和 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest E.) 2019ICPC西安邀请赛现场赛重现赛

    Tree Ming and Hong are playing a simple game called nim game. They have nn piles of stones numbered  ...

  2. 计蒜客 39280.Travel-二分+最短路dijkstra-二分过程中保存结果,因为二分完最后的不一定是结果 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest M.) 2019ICPC西安邀请赛现场赛重现赛

    Travel There are nn planets in the MOT galaxy, and each planet has a unique number from 1 \sim n1∼n. ...

  3. 计蒜客 39279.Swap-打表找规律 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest L.) 2019ICPC西安邀请赛现场赛重现赛

    Swap There is a sequence of numbers of length nn, and each number in the sequence is different. Ther ...

  4. 计蒜客 39270.Angel's Journey-简单的计算几何 ((The 2019 ACM-ICPC China Shannxi Provincial Programming Contest C.) 2019ICPC西安邀请赛现场赛重现赛

    Angel's Journey “Miyane!” This day Hana asks Miyako for help again. Hana plays the part of angel on ...

  5. 计蒜客 28317.Growling Gears-一元二次方程的顶点公式 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 G)

    G. Growling Gears 传送门 此题为签到题,直接中学的数学知识点,一元二次方程的顶点公式(-b/2*a,(4*a*c-b*b)/4*a):直接就可以得到结果. 代码: #include& ...

  6. C.0689-The 2019 ICPC China Shaanxi Provincial Programming Contest

    We call a string as a 0689-string if this string only consists of digits '0', '6', '8' and '9'. Give ...

  7. B.Grid with Arrows-The 2019 ICPC China Shaanxi Provincial Programming Contest

    BaoBao has just found a grid with $n$ rows and $m$ columns in his left pocket, where the cell in the ...

  8. The 2019 ACM-ICPC China Shannxi Provincial Programming Contest (西安邀请赛重现) J. And And And

    链接:https://nanti.jisuanke.com/t/39277 思路: 一开始看着很像树分治,就用树分治写了下,发现因为异或操作的特殊性,我们是可以优化树分治中的容斥操作的,不合理的情况只 ...

  9. 2019计蒜客信息学提高组赛前膜你赛 #2(TooYoung,TooSimple,Sometimes Naive

    计蒜客\(2019CSP\)比赛第二场 巧妙爆零这场比赛(我连背包都不会了\(QWQ\) \(T1\) \(Too\) \(Young\) 大学选课真的是一件很苦恼的事呢! \(Marco\):&qu ...

随机推荐

  1. Javascript判断参数类型

    function (options, param) { alert(typeof options); if (typeof options == "string") { alert ...

  2. 2019 58同城java面试笔试题 (含面试题解析)

    本人3年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.58同城等公司offer,岗位是Java后端开发,最终选择去了58同城. 面试了很多家公司,感觉大部分公司考察的点 ...

  3. Windows双系统

    基础概念 基础概念 Legacy:传统BIOS传输模式启动顺序:开机→BIOS初始化→BIOS自检→引导操作系统→进入系统.传统硬盘引导记录为MBR格式,MBR无法支持超过2T的硬盘.但拥有最好的兼容 ...

  4. Linux理论小结

    1.Linux是什么 2.Linux的种类 3.Linux的软件安装方法 4.Linux的软卸载方法 5.Linux的目录功能 1.Linux是什么 2.Linux的种类 3.Linux的软件安装方法 ...

  5. python笔记--------一

    作用域: 每个变量或函数都有自己的作用域. 每个函数都定义了一个命名空间,也称为作用域. 在最顶层有一个符号表会跟踪这一层所有的名称定义和和他们当前的绑定. 调用函数时,会建立一个新的符号表(常称为栈 ...

  6. javascript数据结构与算法——列表

    前言: 1. 数据的存储结构顺序不重要,也不必对数据进行查找,列表就是一种很好的数据存储结构; 2.此列表采用仿原生数组的原型链上的方法来写,具体可以参考MDN数组介绍,并么有用prototype来构 ...

  7. spark 程序 windows 运行报错

    1 java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. at ...

  8. Pollard-rho的质因数分解

    思路:见参考文章(原理我是写不粗来了) 代码: 用到了快速幂,米勒罗宾素性检验. #include <iostream> #include <time.h> #include ...

  9. linux卸载及安装mysql 5.7以上

    删除: 1.rpm -qa|grep -i mysql     查看安装的mysql 2./usr/local/mysql/support-files/mysql.server stop  停止mys ...

  10. 算法图解(python3版本)--读后感

    本想写详细点,但入门书籍没啥干货,一天就看完了,简单介绍下: 大纲--两方面 一.介绍算法是什么:算法的作用,判断算法效率高低的指标 ①通过编程解决问题的思路,或者说程序本身就是算法,算法作用是为了提 ...