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 ... 
随机推荐
- poj 3013 Big Christmas Tree (最短路径Dijsktra) -- 第一次用优先队列写Dijsktra
			http://poj.org/problem?id=3013 Big Christmas Tree Time Limit: 3000MS Memory Limit: 131072K Total S ... 
- mysql  连接多行  合并多行
			group_concat() select group_concat(id) from xxxx -------------------------------------------- id1,id ... 
- 使用Flexbox实现CSS竖向居中
			竖向居中需要一个父元素和一个子元素合作完成. <div class="flexbox-container"> <div>Blah blah</div& ... 
- Samza在YARN上的启动过程 =》 之一
			运行脚本,提交job 往YARN提交Samza job要使用run-job.sh这个脚本. samza-example/target/bin/run-job.sh --config-factory= ... 
- TaskTracker获取并执行map或reduce任务的过程(一)
			我们知道TaskTracker在默认情况下,每个3秒就行JobTracker发送一个心跳包,也就是在这个心跳包中包含对任务的请求.JobTracker返回给TaskTracker的心跳包中包含有各种a ... 
- Python:使用threading模块实现多线程编程
			转:http://blog.csdn.net/bravezhe/article/details/8585437 Python:使用threading模块实现多线程编程一[综述] Python这门解释性 ... 
- Java Code Examples for org.springframework.http.HttpStatus
			http://www.programcreek.com/java-api-examples/index.php?api=org.springframework.http.HttpStatus 
- [itint5]两数积全为1
			http://www.itint5.com/oj/#18 这一题,首先如果直接去算的话,很容易就超出int或者long的表示范围了.那么要利用%的性质,(num * 10 + 1) % a = 10 ... 
- 一步一步制作yaffs/yaffs2根文件系统(三)---使用glibc库构造 /lib
			开发环境:Ubuntu 12.04 开发板:mini2440 256M NandFlash 64M SDRAM glibc库:点此下载 交叉编译器:arm-linux-gcc 4.4.3点此可下 ... 
- WinCE启动失败的原因与解决办法分析
			本文通过一个真实的嵌入式项目进行说明.文中的嵌入式系统用的是ARM处理器+WinCE平台,项目的目的是要把WinCE平台从旧版本移植到WinCE6.0平台上.但结果是这个WinCE系统在启动的时候经常 ... 
