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. maven安装本地jar到本地仓库

    注册到本地仓库 mvn install:install-file -DgroupId=cn.endv -DartifactId=endv-api -Dversion=1.0.1 -Dpackaging ...

  2. NMS(non maximum suppression,非极大值抑制)

    """nms输入的数据为box的左上角x1,y1与右下角x2,y2+confidence,rows=batch_size,line=[x1,y1,x2,y2,confid ...

  3. Java多线程并发同步执行

    https://www.cnblogs.com/pengdai/p/12026959.html 并发关键字:volatile,final,synchronized Collections: 并发集合 ...

  4. 2019-07-23 static 和 const 关键字的应用

    首先先来了解下内存段,内存段共分为四个,栈.堆.代码段.初始化静态段.程序中不同的声明存放在不同的内存段内,栈空间段是存储占用相同空间长度并且占用空间小的数据类型的地方,比如说整型1, 10, 100 ...

  5. Android常用优秀开源框架整理

    前言 AOSF:全称为Android Open Source Framework,即Android优秀开源框架汇总.包含:网络请求okhttp,图片下载glide,数据库greenDAO,链式框架Rx ...

  6. 一个工作13年的SAP开发人员的回忆:电子科技大学2000级新生入学指南

    让我们跟着Jerry的文章,一起回到本世纪初那个单纯美好的年代. 2000年9月,Jerry告别了自己的高中时代,进入到自己心目中的电子游戏大学,开始了四年的本科生活.每个新生,都拿到了这样一本薄薄的 ...

  7. Clickhouse高可用配置总结

    1. 简述 Clickhouse默认是多分片单副本集群,分布式表的配置是每个分片只有一份,如果某个节点挂掉的话,则会直接导致写入或查询异常:Clickhouse是具有高可用特性的,即每个分片具有2个或 ...

  8. MySQL Backup--Xtrabackup介绍

    Xtrabackup介绍 Xtrabackup是由Percona公司研发的开源热备工具,支持MYSQL 5.0 以上版本. 由于Xtrabackup支持备份innodb表,实际生产环境中我们使用的工具 ...

  9. Linux命令——chgrp、chown、chmod

    简介 这三个命令都用于更改文件permission(权限).即下图红框位置 除此之外还有个“连结”,那个指的是硬链接,不是软连接.FS使用inode区分不同文件,而目录树使用文件名区分不同文件,因此可 ...

  10. [LIN].LIN总线详解

    转自:https://www.2cto.com/kf/201806/754227.html 参考:https://wenku.baidu.com/view/a9b08d786bd97f192379e9 ...