NOJ [1293] Porter Cai
来源:互联网 发布:plc编程基础知识 编辑:程序博客网 时间:2024/06/17 19:23
。。。妈蛋,今天完全没动力想题目啊,难道是老蔡走了的缘故,老蔡
...贪心题,不难
#include<stdio.h>#include<algorithm>using namespace std;int num[10010];int cmp(int a,int b){return a>b;}int main(){int n,w;while(~scanf("%d%d",&n,&w)){int i,j;int ans=0;int temp,len=0;while(n--){scanf("%d",&temp);if(temp>=w) ans++; else num[len++]=temp;}sort(num,num+len,cmp);i=0;j=len-1;while(i<=j){if(i!=j){if(num[i]+num[j]<=w){ans++;i++;j--;}else{ans++;i++;}}else{ans++;break;}}printf("%d\n",ans);}return 0;}
0 0
- NOJ [1293] Porter Cai
- NOJ——[1234] Mr.Cai\'s Field
- Noj
- 浅谈CAI设计
- The Porter Stemming Algorithm
- Porter-Duff简介
- Alpha compositing & Porter-Duff model
- 英文分词算法(Porter stemmer)
- 英文分词算法(Porter stemmer)
- Porter Algorithm ---------词干提取算法
- Android绘图Porter-Duff规则
- Porter Algorithm ---------词干提取算法
- 英文分词算法(Porter stemmer)
- 浅谈对CAI课件的认识
- My Love-letter To Cai III
- HOJ 3057 Cai's DOTA game
- 关于计算机辅助“发明”(CAI)的设想
- 关于计算机辅助“发明”(CAI)的设想
- 素因子分解&&素因子分解求最大公约数&&素因子分解求最小公倍数
- ZOJ-2876
- Cocos2d-x 程序是如何开始运行与结束的
- 100个windows平台C++开发错误之数组
- pySerial -- Python的串口通讯模块
- NOJ [1293] Porter Cai
- 年龄大了还可以学习编程吗
- oracle归档日志
- 【1】Maven安装
- 【LeetCode】Climbing Stairs
- Add Two Numbers
- Color Me Less
- oracle去掉字符串中所有指定字符
- DOC转PDF的vbs脚本