【贪心】XMU 1061 Ckp的约会
题目链接:
http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1061
题目大意:
n个任务(n<=1000),给定名字和开始、结束时间,求最多能完成几个任务。
题目思路:
【贪心】
先按照结束时间排序,之后能取就取,最后输出答案。
//
//by coolxxx
//
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define eps (1e-8)
#define J 10000000
#define MAX 0x7f7f7f7f
#define PI 3.1415926535897
#define N 1004
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
bool mark[N];
struct xxx
{
char name[];
int st,et;
}a[N];
bool cmp(xxx aa,xxx bb)
{
return aa.et<bb.et;
}
int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j,k;
// for(scanf("%d",&cas);cas;cas--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s))
while(~scanf("%d",&n))
{
for(i=;i<=n;i++)
{
scanf("%s",a[i].name);
scanf("%d:%d",&j,&k);a[i].st=(j-)*+k;
scanf("%d:%d",&j,&k);a[i].et=(j-)*+k;
}
sort(a+,a++n,cmp);
for(i=,j=;i<=n;i++)
{
if(a[i].st>=a[j].et)ans++,j=i,mark[i]=;
}
printf("%d\n",ans);
for(i=;i<=n;i++)
if(mark[i])printf("%s ",a[i].name);
puts("");
}
return ;
}
/*
// //
*/
千万不要点
【贪心】XMU 1061 Ckp的约会的更多相关文章
- poj 1061 青蛙的约会 拓展欧几里得模板
// poj 1061 青蛙的约会 拓展欧几里得模板 // 注意进行exgcd时,保证a,b是正数,最后的答案如果是负数,要加上一个膜 #include <cstdio> #include ...
- ACM: POJ 1061 青蛙的约会 -数论专题-扩展欧几里德
POJ 1061 青蛙的约会 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%lld & %llu Descr ...
- POJ.1061 青蛙的约会 (拓展欧几里得)
POJ.1061 青蛙的约会 (拓展欧几里得) 题意分析 我们设两只小青蛙每只都跳了X次,由于他们相遇,可以得出他们同余,则有: 代码总览 #include <iostream> #inc ...
- poj 1061 青蛙的约会 (扩展欧几里得模板)
青蛙的约会 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Submit Status ...
- POJ 1061青蛙的约会(拓展欧几里德算法)
题目链接: 传送门 青蛙的约会 Time Limit: 1000MS Memory Limit: 65536K Description 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见 ...
- POJ 1061 青蛙的约会
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 82859 A ...
- Poj 1061 青蛙的约会(扩展GCD)
题目链接:http://poj.org/problem?id=1061 解题报告:两只青蛙在地球的同一条纬度线上,选取一个点位坐标轴原点,所以现在他们都在同一个首尾相连的坐标轴上,那么他们现在的位置分 ...
- poj 1061青蛙的约会
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 90083 Accepted: 16257 Descripti ...
- 【POJ】 1061 青蛙的约会(扩欧)
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 119148 Accepted: 25070 Descript ...
随机推荐
- [PWA] 6. Hijacking response
For example, if the url is not match to any API endpoint, we want to return 404 error message. So fi ...
- [PWA] 2. Service worker life cycle
Once serive worker is registered, the first time we go to the app, we cannot see the logs from servc ...
- URL重写:RewriteCond指令与RewriteRule 指令格式(转)
Rewirte主要的功能就是实现URL的跳转和隐藏真实地址,基于Perl语言的正则表达式规范.平时帮助我们实现拟静态,拟目录,域名跳转,防止盗链等.本文将针对mod_rewrite和URL匹配的技术细 ...
- diy 电脑 重装系统
1\组装好电脑 2\硬盘的红灯只亮一会,找不到 硬盘 .bios里 硬盘设置里 IDE修改为 ACHI即可. 3\老毛桃 \ 用桌面的那个分区软件 分区 100G,300G 4\找到U盘 的iso 文 ...
- [转] tomcat结合nginx使用小结
相信很多人都听过nginx,这个小巧的东西慢慢地在吞食apache和IIS的份额.那究竟它有什么作用呢?可能很多人未必了解. 说到反向代理,可能很多人都听说,但具体什么是反向代理,很多人估计就不清楚了 ...
- Eclipse中使用git把项目导入到osc@git中
方便Eclipse用户使用Git把项目导入到osc@git中进行管理. Eclipse Git osc@git 一.原有项目: 项目名为TestGit 二.在osc@git上面创建一个新项目库. 填 ...
- 2015 UESTC Training for Search Algorithm & String - M - Palindromic String【Manacher回文串】
O(n)的复杂度求回文串:Manacher算法 定义一个回文值,字符串S是K重回文串,当且仅当S是回文串,且其长度为⌊N/2⌋的前缀和长度为⌊N/2⌋的后缀是K−1重回文串 现在给一个2*10^6长度 ...
- Lucene全文检索
Lucene写入和更新操作: if (id.equals("")) { this.goodsService.save(goods); String goods_lucene_pat ...
- sql server 2008 评估期已过期
解决办法: 修改注册表: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\100\ConfigurationState里的&quo ...
- jquery获取元素到屏幕底的可视距离
jquery获取元素到屏幕底的可视距离 要打对号的图里的height(我自称为可视高度:滚动条未滑到最底端) 不是打叉图里的到页面底部(滚动条到最底部时的height)(offset().top方法 ...