HDU3697 Selecting courses
来源:互联网 发布:ads仿真软件下载 编辑:程序博客网 时间:2024/06/03 14:16
HDU3697
对课程结束时间由小到大进行排序,之后直接暴力枚举。
AC代码:
#include <bits/stdc++.h>using namespace std;const int maxn=300+5;struct node{ int start,end;};node a[maxn];bool vis[maxn];bool cmp(node a,node b){ if(a.end==b.end) return a.start<b.start; return a.end<b.end;}int main(){ //freopen("a.txt","r",stdin); int n; while(~scanf("%d",&n)){ int max=0; if(n==0) break; for(int i=0;i<n;i++) scanf("%d%d",&a[i].start,&a[i].end); sort(a,a+n,cmp); for(int i=0;i<5;i++){ int temp=0; memset(vis,false,sizeof(vis)); for(int j=i;j<a[n-1].end;j+=5){ for(int k=0;k<n;k++) if(vis[k]==false && j>=a[k].start && j<a[k].end){ vis[k]=true; temp++; break; } } //cout<<temp<<endl; if(temp>max) max=temp; } printf("%d\n",max); } return 0;}
0 0
- HDU3697 Selecting courses
- hdu3697 Selecting courses (贪心+暴力)
- PKU_2239 Selecting Courses
- pku2239 Selecting Courses
- POJ 2239 Selecting Courses
- poj 2239 Selecting Courses
- POJ-2239 Selecting Courses
- 二分匹配 Selecting Courses
- poj 2239 Selecting Courses
- POJ 2239 Selecting Courses
- poj2239 - Selecting Courses
- POJ-2239-Selecting Courses
- poj 2239 Selecting Courses
- poj2239 Selecting Courses
- poj Selecting Courses
- POJ2239:Selecting Courses
- POJ 2239-Selecting Courses
- poj 2239 Selecting Courses
- Codeforces Round #375 (Div. 2) -- C. Polycarp at the Radio(水题)
- 10.3
- CC150 2.6/Leetcode Palindrome LinkedList
- 1.印光法师文钞嘉言录题词及重排序
- 【Maven实战】07 生命周期和插件
- HDU3697 Selecting courses
- db类利用config.php文件完成连接配置
- 一张图带你看Linux内核运行原理
- Oracle 序列 Sequence
- Python爬虫入门学习例子之百度贴吧
- TSP旅行商时间复杂度与空间复杂度
- 数字图像处理一
- 重置Hana数据库SYSTEM用户口令
- JAVA进阶6.6——买票问题