ural 1203. Scientific Conference(动态规划)
1203. Scientific Conference
Input
Output
Sample
| input | output |
|---|---|
5 |
3 |
#include <cstring>
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
struct node
{
int x,y;
} p[];
int flag[];
int cmp(node a,node b)
{
if(a.x == b.x)
return a.y < b.y;
else
return a.x < b.x;
}
int main()
{
freopen("1.txt","r",stdin);
int n,i,j,ans,maxz,top;
scanf("%d",&n);
for(i =; i < n; i ++)
{
scanf("%d%d",&p[i].x,&p[i].y);
}
memset(flag,-,sizeof(flag));
sort(p,p+n,cmp);
ans=;
flag[] = p[].y;
top = ;
for(i =;i<n;i++)
{
maxz = ;
for(j=top;j>=;j--)
{
if(p[i].x>flag[j])
{
maxz=j;
break;
}
}
if(flag[maxz+]==-)
{
flag[maxz+] = p[i].y;
top ++;
}
else
flag[maxz+] = min(flag[maxz+],p[i].y);
}
printf("%d\n",top);
}
ural 1203. Scientific Conference(动态规划)的更多相关文章
- URAL 1203 Scientific Conference(贪心 || DP)
Scientific Conference 之前一直在刷计算几何,邀请赛连计算几何的毛都买见着,暑假这一段时间就做多校.补多校的题目.刷一下一直薄弱的DP.多校假设有计算几何一定要干掉-.- 题意:给 ...
- ural 1203. Scientific Conference
http://acm.timus.ru/problem.aspx?space=1&num=1203 #include <cstdio> #include <cstring&g ...
- URAL 1203 Scientific Conference 简单dp 难度:0
http://acm.timus.ru/problem.aspx?space=1&num=1203 按照结束时间为主,开始时间为辅排序,那么对于任意结束时间t,在此之前结束的任务都已经被处理, ...
- URAL 1203. Scientific Conference(瞎搞)
题目链接 本来觉得这不是经典的贪心吗..果断水一次,wa了,看了看discuss,发现貌似不好水,土土的DP了一下,复杂度很高了,又T了...然后想想单调队列,二分什么的...不好往上加,直接搞了标记 ...
- URAL 1203 Scientific Conference dp?贪心
题目:click here 分明就是贪心怎么会在dp的专题 #include <bits/stdc++.h> using namespace std; typedef unsigned l ...
- bzoj1814: Ural 1519 Formula 1 动态规划 插头dp
http://acm.timus.ru/problem.aspx?space=1&num=1519 题目描述 一个 m * n 的棋盘,有的格子存在障碍,求经过所有非障碍格子的哈密顿回路个数. ...
- URAL DP第一发
列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scient ...
- URAL(DP集)
这几天扫了一下URAL上面简单的DP 第一题 简单递推 1225. Flags #include <iostream> #include<cstdio> #include< ...
- ACM会议列表与介绍(2014/05/06)
Conferences ACM SEACM Southeast Regional Conference ACM Southeast Regional Conference the oldest, co ...
随机推荐
- CodeForces 677D Vanya and Treasure
$dp$,树状数组. 很明显这是一个$DAG$上的$dp$,由于边太多,暴力$dp$会超时,需要优化. 例如计算$dp[x][y]$,可以将区域分成四块,$dp[x][y]$取四块中的最小值,每一块用 ...
- HDU 1040 As Easy As A+B(排序)
As Easy As A+B Problem Description These days, I am thinking about a question, how can I get a probl ...
- Angular JS Scope(作用域)
Scope(作用域) 是应用在 HTML (视图) 和 JavaScript (控制器)之间的纽带. Scope 是一个对象,有可用的方法和属性. Scope 可应用在视图和控制器上. 当你在 Ang ...
- python hmac-sha1
def getSignature(Token,paramss1): s = getParam(paramss1) print(s) # for k, v in paramss1.items(): # ...
- JAVA 程序发布引发性能抖动
发布或重启线上服务时抖动问题解决方案 一.问题描述 在发布或重启某线上某服务时(jetty8作为服务器),常常发现有些机器的load会飙到非常高(高达70),并持续较长一段时间(5分钟)后 ...
- 关于angularjs依赖注入的整理
初学angularjs阶段,刚刚看到菜鸟教程的angularjs依赖注入.现在整理一下: 1.含义:一个或更多的依赖(可以理解为模块关系依赖)或服务(分为内建服务[例如$http,$tiomeout等 ...
- Mongo组合索引优化
包含了等值测试.排序及范围过滤查询的索引建立方法: 1. 等值测试 在索引中加入所有需要做等值测试的字段,任意顺序. 2. 排序字段(多排序字段的升/降序问题 ) 根据查询的顺序有序的向索引中添加字段 ...
- jfianl返回自定义的404页面
public class MyErrorRenderFactory implements IErrorRenderFactory{ public Render getRender(int errorC ...
- poi做Excel数据驱动,支持.xls和.xlsx格式的excel文档,比起jxl强大不少
import java.io.FileInputStream;import java.io.InputStream;import java.util.Iterator;import java.util ...
- 设计模式 -- 解释器模式(Interpreter Pattern)
2015年12月15日00:19:02 今天只看了理论和demo,明天再写文章,跑步好累 2015年12月15日21:36:00 解释器模式用来解释预先定义的文法. <大话设计模式>里面这 ...