TOJ 3982.Vacation
来源:互联网 发布:海隆软件 编辑:程序博客网 时间:2024/05/01 21:20
题目链接:http://acm.tju.edu.cn/toj/showp3982.html
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 416 Accepted Runs: 248
Z is planning to visit the Tourist Kingdom for M days. This kingdom is full of lovely cities. During his stay Z would like to visit as many different cities as possible. He cannot visit more than one city on the same day.
Additionally,different cities may require him to stay for a different number of days.For each i,city i counts as visited if Z spends at least d[i] days in the city.
Help Z find the maximal number of cities he can visit during his vacation.
Input
First a integer T,the number of test cases.For each test case,the first line is M and N,the total days Z has and the number of cities.(M,N≤50)
Then N integers,meaning the int[] d.
Output
The maximal number of cities Z can visit.
Sample Input
35 32 2 25 35 6 16 51 1 1 1 1
Sample Output
215
Source: TJU Team Selection 2013
水题,水的不能再水的题,排序然后贪心。说多了直接上代码好了。。。
#include <stdio.h>#include <algorithm>using namespace std;int main(){int n,m,t,city[51],sum;scanf("%d",&t);while(t--){scanf("%d%d",&n,&m);sum=0;for(int i=0;i<m;i++)scanf("%d",&city[i]);sort(city,city+m);for(int i=0;i<m;i++)if(n>=city[i]){sum++;n-=city[i];}else break;printf("%d\n",sum);}}
- TOJ 3982.Vacation
- Vacation
- vacation
- long vacation??
- 10192 - Vacation
- TJU Vacation
- uva1133---Vacation
- UVaOJ_10192 - Vacation
- UVA10192- Vacation
- uva10192-Vacation
- Vacation 自动回信程序
- uva 10192 Vacation
- UVa 10192. Vacation
- UVa 10192 - Vacation
- UVA 10192 Vacation
- UVA 10192 Vacation
- UVa 10192 - Vacation
- UVa 10192 - Vacation
- linux下安装mysql
- gulp篇:速度上手,执行我们第一个任务
- 删除JAVA集合中元素的实现代码
- Nuclear Arms Race
- 数据结构实验之二叉树二:遍历二叉树
- TOJ 3982.Vacation
- JS中Attribute 和 property的区别
- JZOJ4683 矩阵
- 划分树
- 数据结构实验之二叉树的建立与遍历
- 3000门徒内部训练绝密视频(泄密版)第9课:彻底实战详解使用IntelliJ IDEA下的Spark程序开发
- ubuntu下搭建android开发环境(一)安装ubuntu系统(by 星空武哥)
- 我的开发之路-与你同行
- java中ArrayList 、LinkList的区别分析---程序中设比较时间