HDU 3697贪心
额...大意是你可以决定什么时候选课。然后呢。每五分钟只有一次机会选。每种课限制选课时间。问你能选到的课最多有多少、
感觉一点都不水。是自己太菜了吗?
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std; struct Node
{
int l, r;
} node[]; int cmp(Node a, Node b)
{
if (a.r != b.r) return a.r <b.r;
return a.l <= b.l;
} int main()
{
int n;
while(cin >> n)
{
if (n == ) break;
for (int i=; i<n; ++i)
{
cin >> node[i].l >> node[i].r;
}
sort(node, node+n, cmp);
int ans = ;
int vis[];
memset(vis, , sizeof(vis)); for (int i=; i<; ++i)
{
int st = i;
int tans = ;
memset(vis, , sizeof(vis));
//for (st=i; st<=node[n-1].r; st+=5)
while(st <= node[n-].r)
{
for (int j=; j<n; ++j)
{
if (vis[j]) continue;
if (node[j].l < st && node[j].r >= st)
{
//st += 5;
vis[j] = ;
tans += ;
break;
}
//st += 5;
}
st += ;
}
ans = max(ans, tans);
}
cout << ans << endl;
}
return ;
}
HDU 3697贪心的更多相关文章
- hdu 3697 贪心
#include<stdio.h> #include<stdlib.h> #include<string.h> #define inf 0x3fffffff #de ...
- HDU 3697 Selecting courses(贪心)
题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Prob ...
- hdu 3697 10 福州 现场 H - Selecting courses 贪心 难度:0
Description A new Semester is coming and students are troubling for selecting courses. Students ...
- HDU 3697 Selecting courses 选课(贪心)
题意: 一个学生要选课,给出一系列课程的可选时间(按分钟计),在同一时刻只能选一门课程(精确的),每隔5分钟才能选一次课,也就是说,从你第一次开始选课起,每过5分钟,要么选课,要么不选,不能隔6分钟再 ...
- HDU 3697 Selecting courses(贪心+暴力)(2010 Asia Fuzhou Regional Contest)
Description A new Semester is coming and students are troubling for selecting courses. Students ...
- hdu 3697 Selecting courses (暴力+贪心)
Selecting courses Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 62768/32768 K (Java/Others ...
- Hdu 5289-Assignment 贪心,ST表
题目: http://acm.hdu.edu.cn/showproblem.php?pid=5289 Assignment Time Limit: 4000/2000 MS (Java/Others) ...
- hdu 4803 贪心/思维题
http://acm.hdu.edu.cn/showproblem.php?pid=4803 话说C++还卡精度么? G++ AC C++ WA 我自己的贪心策略错了 -- 就是尽量下键,然后上 ...
- hdu 1735(贪心) 统计字数
戳我穿越:http://acm.hdu.edu.cn/showproblem.php?pid=1735 对于贪心,二分,枚举等基础一定要掌握的很牢,要一步一个脚印走踏实 这是道贪心的题目,要有贪心的意 ...
随机推荐
- TCP 的连接建立:采用三报文握手
- C# string字节数组转换
string转byte[]:byte[] byteArray = System.Text.Encoding.Default.GetBytes ( str ); byte[]转string:string ...
- Package libvirt was not found in the pkg-config search path
关于pip安装libvirt-python的时候提示Package libvirt was not found in the pkg-config search path的问题解决方法 1.一开始以为 ...
- centos6搭建redis集群搭建(单机多节点)
一.安装redis 1.安装gcc环境 yum install gcc-c++ 2.下载源码包并解压 wget http://download.redis.io/releases/redis-3.2. ...
- url rewrite导致的500.19 0x8007000d
https://stackoverflow.com/questions/13532447/http-error-500-19-iis-7-5-error-0x8007000d It seems you ...
- C++作业:Circle_area
Github链接: Circle_area 代码: main.cpp #include "circle_area.h" #include <iostream> #inc ...
- HDU 1083 Courses(二分图匹配模板)
http://acm.hdu.edu.cn/showproblem.php?pid=1083 题意:有p门课和n个学生,每个学生都选了若干门课,每门课都要找一个同学来表演,且一个同学只能表演一门课,判 ...
- Ubuntu 14.04设置开机启动脚本的方法
rc.local脚本 rc.local脚本是一个ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令.该脚本位于/etc/路径下,需要root权限才能修改. 该脚本具体格式如下: #! ...
- shell while 语句
普通循环格式: while condition do command done 例子一 #!/bin/bash )) do echo $int let "int++" done 结 ...
- Netcat使用方法
netcat被誉为网络安全界的‘瑞士军刀',相信没有什么人不认识它吧...... 一个简单而有用的工具,透过使用TCP或UDP协议的网络连接去读写数据.它被设计成一个稳定的后门工具,能够直接由其它 ...