URAL 1203 Scientific Conference 简单dp 难度:0
http://acm.timus.ru/problem.aspx?space=1&num=1203
按照结束时间为主,开始时间为辅排序,那么对于任意结束时间t,在此之前结束的任务都已经被处理,从这个时间开始的任务都正要被处理,
因为t<=3e5,可以用简单dp解决
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=1e5+5;
int n;
typedef pair<int,int> P;
P t[maxn];
int dp[maxn];
int ans;
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d",&t[i].first,&t[i].second);
}
sort(t,t+n);
for(int i=1,j=0;i<=30001;i++){
ans=max(ans,dp[i-1]); if(j==n||i<t[j].first)continue;
while(t[j].first==i){
dp[t[j].second]=max(dp[t[j].second],ans+1);
j++;
}
}
printf("%d\n",ans);
return 0;
}
URAL 1203 Scientific Conference 简单dp 难度:0的更多相关文章
- ural 1203. Scientific Conference(动态规划)
1203. Scientific Conference Time limit: 1.0 second Memory limit: 64 MB Functioning of a scientific c ...
- URAL 1203 Scientific Conference(贪心 || DP)
Scientific Conference 之前一直在刷计算几何,邀请赛连计算几何的毛都买见着,暑假这一段时间就做多校.补多校的题目.刷一下一直薄弱的DP.多校假设有计算几何一定要干掉-.- 题意:给 ...
- URAL 1203 Scientific Conference dp?贪心
题目:click here 分明就是贪心怎么会在dp的专题 #include <bits/stdc++.h> using namespace std; typedef unsigned l ...
- ural 1203. Scientific Conference
http://acm.timus.ru/problem.aspx?space=1&num=1203 #include <cstdio> #include <cstring&g ...
- URAL 1203. Scientific Conference(瞎搞)
题目链接 本来觉得这不是经典的贪心吗..果断水一次,wa了,看了看discuss,发现貌似不好水,土土的DP了一下,复杂度很高了,又T了...然后想想单调队列,二分什么的...不好往上加,直接搞了标记 ...
- ural 1009. K-based Numbers(简单dp)
http://acm.timus.ru/problem.aspx?space=1&num=1009 题意:将一个n位数转化为合法的K进制数,有多少种情况.合法的K进制数即不含前导0,且任意两个 ...
- Uva LA 3902 - Network 树形DP 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- ZOJ 3822 Domination 概率dp 难度:0
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
- 快速切题 sgu104. Little shop of flowers DP 难度:0
104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM Yo ...
随机推荐
- 前端使用canvas绘制立体三角形
前端绘制立体效果的三角形的demo 在移动端使用时,需要自适应屏幕.canvas上无法设置rem,所以在canvas外加一个父级元素设置为rem,再将canvas的宽高设置为100% 100%. 如果 ...
- vmware 虚拟机三种网卡
转:https://blog.csdn.net/lyf_ldh/article/details/78695357 vmware为我们提供了三种网络工作模式,它们分别是:Bridged(桥接模式).NA ...
- 为什么iterator,foreach遍历时不能进行remove操作?除了一种情况可以这样(特殊情况)?
Exception in thread "main" java.util.ConcurrentModificationException 并发修改异常引发的思考! 1 foreac ...
- pom.xml常用元素解析
project 最外层元素 modelVersion 指定Maven模型的版本号,对于Maven2和Maven3,它只能是4.0.0 version 版本信息 groupId 包id,会生成相应路径 ...
- Win10下配置Java 环境变量
在Win10中配置环境变量的方法跟在Win8和Win7中有些不同,看了看网上好多还是Win7/8里面的配置方法.虽然从原理上基本上没什么问题,但有些细节却会让人很苦恼.特意整理下新的配置方法.我假定你 ...
- Alluxio集成Hadoop
准备工作 为了运行Alluxio集群在多个机器上,必须部署Alluxio服务到这些机器上.可以下载伴随特定Hadoop版本的二进制AlLxio包,也可以从Alluxio源码中编译. 当从源码中编译时, ...
- integration asp.net web api with autofac and owin
There is an example project showing Web API in conjunction with OWIN self hosting https://github.com ...
- Permission denied: mod_fcgid
[Tue Jun 16 13:29:08 2015] [warn] (13)Permission denied: mod_fcgid: spawn process /var/www/cgi-bin/g ...
- Vue2.0 + ElementUI的+ PageHelper实现的表格分页
参考博客:http://blog.csdn.net/u012907049/article/details/70237457 借鉴1.controller层编写 2.vue中,axios的写法(总页数等 ...
- c# iText 生成PDF 有文字,图片,表格,文字样式,对齐方式,页眉页脚,等等等,
#region 下载说明书PDF protected void lbtnDownPDF_Click(object sender, EventArgs e) { int pid = ConvertHel ...