lightOJ 1227 - Boiled Eggs
2015-11-19 20:08
337 查看
贪心,一定要先sort一遍。。。。。。
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int arr[35]; int main() { std::ios::sync_with_stdio(false); int T,cas=0; cin >> T; while (T--) { int n,p,q,res=0,cnt=0; cin >> n >> p >> q; for (int i=0;i < n;i++) cin >> arr[i]; sort(arr,arr+n); for (int i = 0;i < n;i++) { res += arr[i]; if(cnt<p&&res<=q) cnt++; } printf ("Case %d: %d\n",++cas,cnt); } return 0; }
相关文章推荐
- MySql ibdata1文件瘦身
- 【甘道夫】HBase(0.96以上版本)过滤器Filter详解及实例代码
- iOS NSMutableArray "removeObjectIdenticalTo" vs "removeObject"
- Convolutional Networks
- 结构型模式
- 内存泄露从入门到精通三部曲之常见原因与用户实践
- ### Error building SqlSession.
- 芒果iOS开发UI课程第三节UITextField
- android shape的使用
- Resid 学习笔记1-基础命令
- TS科普14 节目特定信息
- OpenCV获取RTSP解码播放
- Manifest文件
- 如何做好一个面试官——之学习篇
- Android事件传递之子View和父View的那点事
- java 全局按键 swing
- linux的远程登陆管理
- 数据库 --> sqlite3总结
- 求职者和面试官如何做好电话面试
- HDOJ 1392 Surround the Trees (凸包)