计蒜客 39268.Tasks-签到 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest A.) 2019ICPC西安邀请赛现场赛重现赛
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_itiseconds. 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西安邀请赛现场赛重现赛的更多相关文章
- 计蒜客 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 ...
- 计蒜客 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. ...
- 计蒜客 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 ...
- 计蒜客 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 ...
- 计蒜客 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& ...
- 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 ...
- 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 ...
- The 2019 ACM-ICPC China Shannxi Provincial Programming Contest (西安邀请赛重现) J. And And And
链接:https://nanti.jisuanke.com/t/39277 思路: 一开始看着很像树分治,就用树分治写了下,发现因为异或操作的特殊性,我们是可以优化树分治中的容斥操作的,不合理的情况只 ...
- 2019计蒜客信息学提高组赛前膜你赛 #2(TooYoung,TooSimple,Sometimes Naive
计蒜客\(2019CSP\)比赛第二场 巧妙爆零这场比赛(我连背包都不会了\(QWQ\) \(T1\) \(Too\) \(Young\) 大学选课真的是一件很苦恼的事呢! \(Marco\):&qu ...
随机推荐
- Django后台管理admin或者adminx中使用富文本编辑器
在admin或者adminx后台中使用富文本编辑器 一.建立模型:(安装django-tinymce==2.6.0) from django.db import models from tinymce ...
- 【转载】C#中Convert.ToSingle方法将字符串转换为Float类型
在C#编程过程中,可以使用Convert.ToSingle方法将字符串或者其他可转换为数字的对象变量转换为float类型,Convert.ToSingle方法有多个重载方法,最常使用的一个方法将字符串 ...
- 学习笔记之编程珠玑 Programming Pearls
Programming Pearls (2nd Edition): Jon Bentley: 0785342657883: Amazon.com: Books https://www.amazon.c ...
- 深入理解es6(上)
一.let和const 1.let与var的区别 不存在变量提升 块级作用域 不允许重复声明 2.const常量 const与let一样,唯一区别在于声明的常量不能被修改 二.解构赋值 es6按照一定 ...
- 【转】java 环境变量:path与classpath区别
path指示java命令的路径,像javac.java.javaw等: classpath是javac编译器的一个环境变量,它的作用与import.package关键字有关,当你写下improt ja ...
- jmeter学习笔记(二十二)——监听器插件之jp@gc系列
一.jp@gc - Actiive Threads Over Time 不同时间活动用户数量展示 下面是一个阶梯加压测试的图标 二.jp@gc - Transactions per Second ...
- 【兼容调试】cffi library '_openssl' has no function, constant or global variable named 'Cryptography_HAS
重装cryptography就好了. conda uninstall cryptography conda install cryptography https://github.com/pyca/c ...
- Flink实战学习资料
这份资料我已经看了一些,感觉挺不错的,在这里分享一下,有需要的可以购买学习.
- Pthon面向对象-特殊属性
Pthon面向对象-特殊属性 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.特殊属性 #!/usr/bin/env python #_*_conding:utf-8_*_ ...
- Gerrit代码评审流程
Gerrit代码评审流程 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.代码评审流程(如下图所示) 第一步:贡献者报建一个提交,并通过之前从gerrit下载的commit-ms ...