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. C#——零散学习1

    C#——零散学习1 //结构体(与C语言相似) struct Position { public float x; public float y;         //不一定需要把结构体成员设置为pu ...

  2. Win10家庭版升级到企业版的方法

    一.家庭版升级企业版 1.右键单击[此电脑]——>属性 2.点击更改产品密钥 3.输入密钥:NPPR9-FWDCX-D2C8J-H872K-2YT43 4.点击下一步,验证结束后点击开始升级,然 ...

  3. Java自学-类和对象 继承

    什么是 Java的 继承 ? 在LOL中,武器是物品的一种,也是有名称和价格的 所以在设计类的时候,可以让武器继承物品,从而继承名称和价格属性 步骤 1 : 物品类Item 物品类Item 有属性 n ...

  4. Python进阶(一)----函数

    Python进阶(一)----函数初识 一丶函数的初识 什么函数: ​ 函数是以功能为导向.一个函数封装一个功能 函数的优点: ​ 1.减少代码的重复性, ​ 2.增强了代码的可读性 二丶函数的结构 ...

  5. 微服务架构ServiceMesh

    公司用的架构,在此找了资料作为记录复看所用: 什么是Service Mesh? Service Mesh的概念最早是由Buoyant公司的CEO William Morgan在一篇文章里提出,他给出的 ...

  6. python day 18: thinking in UML与FTP作业重写

    目录 python day 18 1. thinking in UML读书小感 2. FTP作业重写 2.1 软件目录结构 2.2 FTPClient端脚本 2.3 FTPServer端脚本 pyth ...

  7. vue从零开始(三)指令

    v-bind的使用 <!-- 绑定一个属性 --> <img v-bind:src="imageSrc"> <!-- 动态特性名 (2.6.0+) - ...

  8. 关于创建Web图像时应记住的五个要素

    1. 格式与下载速度 当前,Web上用的最广泛的三种格式是GIF.PNG和JPEG.我们的目标是选择质量最高,同时文件最小的格式. WebP图像格式 谷歌建立了另一种图像格式,名为WebP. 这种格式 ...

  9. Java的基本知识之线程池篇

    1.基本概念 1.共享资源 多个线程对同一份资源进行访问(读写操作),该资源被称为共享资源.如何保证多个线程访问到的数据是一致的,则被称为数据同步或资源同步. 2.线程通信 线程通信,又叫进程内通信, ...

  10. 【转】移植vsftpd到arm linux

    vsftpd即very secure FTP daemon(非常安全的FTP进程),是一个基于GPL发布的类UNIX类操作系统上运行的服务器的名字(是一种守护进程),可以运行在诸如Linux.BSD. ...