题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3721

  容易的贪心题,排个序。。

 //STATUS:C++_AC_840MS_6272KB
#include <functional>
#include <algorithm>
#include <iostream>
//#include <ext/rope>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
//using namespace __gnu_cxx;
//define
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define PI acos(-1.0)
//typedef
//typedef __int64 LL;
//typedef unsigned __int64 ULL;
//const
const int N=;
const int INF=0x3f3f3f3f;
const int MOD=,STA=;
//const LL LNF=1LL<<60;
const double EPS=1e-;
const double OO=1e15;
const int dx[]={-,,,};
const int dy[]={,,,-};
const int day[]={,,,,,,,,,,,,};
//Daily Use ...
inline int sign(double x){return (x>EPS)-(x<-EPS);}
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T lcm(T a,T b,T d){return a/d*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
template<class T> inline T Min(T a,T b,T c){return min(min(a, b),c);}
template<class T> inline T Max(T a,T b,T c){return max(max(a, b),c);}
template<class T> inline T Min(T a,T b,T c,T d){return min(min(a, b),min(c,d));}
template<class T> inline T Max(T a,T b,T c,T d){return max(max(a, b),max(c,d));}
//End struct Node{
int l,r;
int idx;
bool operator < (const Node &a)const {
return l!=a.l?l<a.l:r<a.r;
}
}p[N];
int cnt[N];
vector<int> q[N];
int n; int main()
{
// freopen("in.txt","r",stdin);
int i,j,tot,R;
while(~scanf("%d",&n))
{
tot=;
mem(cnt,);
for(i=;i<=n;i++)q[i].clear();
for(i=;i<n;i++){
scanf("%d%d",&p[i].l,&p[i].r);
p[i].idx=i+;
}
sort(p,p+n); R=-;
for(i=;i<n;i++){
if(p[i].l>=R){
tot++;
R=p[i].r;
}
R=Min(R,p[i].r);
q[tot].push_back(p[i].idx);
cnt[tot]++;
} printf("%d\n",tot);
for(i=;i<=tot;i++){
printf("%d",q[i][]);
for(j=;j<cnt[i];j++)
printf(" %d",q[i][j]);
putchar('\n');
}
putchar('\n');
}
return ;
}

ZOJ-3721 Final Exam Arrangement 贪心的更多相关文章

  1. zoj 3721 Final Exam Arrangement【贪心】

    题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3721 来源:http://acm.hust.edu.cn/vjudg ...

  2. Final Exam Arrangement(ZOJ)

    In Zhejiang University, there are N different courses labeled from 1 to N. Each course has its own t ...

  3. [CF] Final Exam Arrangement

    问题链接:http://www.bnuoj.com/v3/contest_show.php?cid=4329#problem/F   问题大意:         就是有1--N们课程,每一个课程都有一 ...

  4. 【HDOJ6651】Final Exam(贪心)

    题意:有n门课,价值之和为m,每门课的价值可能是0到m 一门价值为x的课需要花至少x+1时间准备才能通过 问不管价值如何分配都能通过至少k门课的最小总准备时间 m,n,k<=1e9 思路: #i ...

  5. HDU 6651 Final Exam (思维)

    2019 杭电多校 7 1006 题目链接:HDU 6651 比赛链接:2019 Multi-University Training Contest 7 Problem Description Fin ...

  6. 2019 Multi-University Training Contest 7 Kejin Player Final Exam

    Kejin Player 期望DP 题意: 初始等级为1,每一级有四个参数 r , s , x , a . 每一级有一个概率p=r/s花费a的代价升级到下一级,失败可能会倒退到x级 设从 l 到 r ...

  7. 2019HDU多校第七场 HDU6651 Final Exam

    一.题目 Final Exam 二.分析 题目说的比较绕,总之一定要记住,$n$个题目都可以做,至少作对$k$到,但是做题目的人不知道每道题对应的分数. 作为出题人,如果他是田忌,肯定不会去在做题目的 ...

  8. Exam(贪心)

    Exam Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  9. hdu 5240 Exam(贪心)

    Exam Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

随机推荐

  1. hdu 5510 Bazinga KMP+尺取法

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 题意:至多50组数据,每组数据至多500个字符串,每个字符串的长度最长为2000.问最大的下标( ...

  2. 关于2440的裸跑程序中SD卡读后不能成功写入问题的讨论

    问题描述: TQ2440的官方裸跑程序中,对SD卡先进行读操作,然后再写,发现不能程序卡死.倘若对SD卡先写后读,程序可以正常运行,奇哉怪哉? 写数据的关键代码--> while(i < ...

  3. EF性能优化(一)

    一:背景 说到EF的性能问题,我相信都是大家比较头痛的问题,有很多初学者望而却步,可是每每菜鸟在群里面抱怨EF太慢的时候,这个时候总有一些大牛登场说一句:怪EF咯?怪你不会用! 当然我从未嫌弃过它,因 ...

  4. C++学习笔记37:元编程

    元编程 什么是元编程(metaprogramming) 利用模板可以进行编译期计算(数值计算,型式计算和代码计算)的特点进行程序设计 为什么可以进行元编程? C++是两层语言:执行编译期计算的代码称为 ...

  5. centos 下 yum 安装 nginx 平滑切换安装到 Tengine

    ---恢复内容开始--- 据说淘宝的Tengine很牛X,所以我们今天也来玩玩,我们这里是某开放云的vps,现在已经安装好了nginx,现在我们要平滑切换到安装Tengine. 下载Tengine,解 ...

  6. loadmore & scroll

    loadmore <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.m ...

  7. 【官方文档】《暗黑世界V1.4》API说明!

    指令号说明 账号注册   100 { username   str     用户名 password   str     密码 } 返回信息 { result     bool    指令调用是否成功 ...

  8. VirtualDub - 开源视频捕捉及线性处理软件

    VirtualDub是一个开放源代码的视频捕捉及线性处理软件.它由Avery Lee编写,遵循GPL协议.VirtualDub可以通过摄像头捕捉视频. 官方网站http://virtualdub.or ...

  9. jacob访问ocx控件方法和遇到的问题

    最近在进行摄像机的二次开发,摄像机厂商提供了使用C++开发的ocx控件:所以尝试使用jacob来进行访问. 操作步骤如下: 1, 从官网(http://sourceforge.net/projects ...

  10. php stdClass Object 问题

    Array ( [0] => stdClass Object ( [term_id] => 3 [name] => apache [slug] => apache [term_ ...