CodeForce---Educational Codeforces Round 3 USB Flash Drives (水题)解题报告
对于这题明显是用贪心算法来解决问题:
下面贴出笔者的代码:
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std; int a[];
bool cmp(int A,int B)
{
return A>B;
}
int main()
{
int n;scanf("%d",&n);
int m;scanf("%d",&m);
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
sort(a+,a++n,cmp);
int ans = ;
for(int i=;i<=n;i++)
{
m-=a[i];
ans++;
if(m<=)break;
}
printf("%d\n",ans);
}
CodeForce---Educational Codeforces Round 3 USB Flash Drives (水题)解题报告的更多相关文章
- Codeforces Educational Codeforces Round 3 A. USB Flash Drives 水题
A. USB Flash Drives 题目连接: http://www.codeforces.com/contest/609/problem/A Description Sean is trying ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- Educational Codeforces Round 7 A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...
- Educational Codeforces Round 11 A. Co-prime Array 水题
A. Co-prime Array 题目连接: http://www.codeforces.com/contest/660/problem/A Description You are given an ...
- Educational Codeforces Round 10 C. Foe Pairs 水题
C. Foe Pairs 题目连接: http://www.codeforces.com/contest/652/problem/C Description You are given a permu ...
- Educational Codeforces Round 24 CF 818 A-G 补题
6月快要结束了 期末也过去大半了 马上就是大三狗了 取消了小学期后20周的学期真心长, 看着各种北方的学校都放假嗨皮了,我们这个在北回归线的学校,还在忍受酷暑. 过年的时候下定决心要拿块ACM的牌子, ...
- Codeforce |Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes
B. Obtain Two Zeroes time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 2 A. Extract Numbers 模拟题
A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...
- Educational Codeforces Round 11 C hard process_补题——作为司老大的脑残粉
司老大当时教了一种姿势枚举连续K个0,说实话当时比赛写这题完全蒙了 纵然后来知道思路还是写了一段时间 真的是.. 题目大意 n长度的序列,由0 1构成 我们可以改变 k个0为1 求可以得到的最长连续1 ...
随机推荐
- shell复习笔记----入门知识
Unix 简史 UNIX 最初是由贝尔实验室(Bell Telephone Laborataries)的计算机科学研究中心开发的,第一版诞生于1970年--也就是在贝尔实验室退出Multics项目不久 ...
- webApp添加到iOS桌面
iOS中的safri浏览器可以将一个网页添加到桌面,当做一个独立的应用运行. 当然,这里我们不讨论怎么去做一个webApp,这需要html5的相关知识和开发经验.这里我们只讲webApp添加桌面后到启 ...
- [转载]汇编eax寄存器和AX,AH,AL之间的关系
00000000 00000000 00000000 00000000|===============EAX===============|---32个0,4个字节,2个字,1个双字 ...
- [转载]WCF序列化65536大小限制的问题
错误: The formatter threw an exception while trying to deserialize the message: There was an error whi ...
- 团体程序设计天梯赛-练习集L1-011. A-B
L1-011. A-B 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 本题要求你计算A-B.不过麻烦的是,A和B都是字符串 — ...
- PHP中CURL方法curl_setopt()函数的一些参数 (转)
bool curl_setopt (int ch, string option, mixed value) curl_setopt()函数将为一个CURL会话设置选项.option参数是你想要的设置, ...
- Stretch a row if data overflows in jasper reports
My band stretches if necessary with the following conditions, I do not know yours. I have started wi ...
- netstat命令查看服务器运行情况
netstat -n|grep 80出现大量time_wait 在运行netstat -n|grep 80 | awk '/^tcp/ {++S[$NF]} END {for(a in S) prin ...
- P38、面试题3:二维数组中的查找
题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数. 首先选取数组中右上角的数字 ...
- cache设计,以及多核造成的不一致性以及解决方案
http://www.360doc.com/content/11/1013/00/1317564_155625188.shtml http://blog.csdn.net/muxiqingyang/a ...