URAL 1203 Scientific Conference dp练习
2015-08-27 11:09
253 查看
Functioning of a scientific conference is usually divided into several simultaneous sections. For example, there may be a section on parallel computing, a section on visualization, a section on data compression, and so on.
Obviously, simultaneous work of several sections is necessary in order to reduce the time for scientific program of the conference and to have more time for the banquet, tea-drinking, and informal discussions. However, it is
possible that interesting reports are given simultaneously at different sections.
A participant has written out the time-table of all the reports which are interesting for him. He asks you to determine the maximal number of reports he will be able to attend.
题目好多词都看不懂 我是英语渣渣 , 于是求助与愚蠢的翻译软件。 果然翻译软件是愚蠢的。
然而,通过努力我自己看懂了。
对于每一个时间,当前时间的最大可以参加的会议数 取前一个时间的值 和当前时间结束的最后一个会议的 开始时间的前一个时间的会议数+1 ,取两者间的大值。 嗯, 果然我也没看懂我在说什 , 上方程
dp[i] = max( dp[i-1] , dp[ t[i] - 1] + 1)
如果在 第i时刻没参加会议或会议还没结束 那么参加的会议数应该和前一时刻相等。 如果该时刻有个会议结束了 ,那么这个时刻的会议数应该是会议开始前的 前一时刻会议数+1。
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 30100
int dp
;
int t
;
int n;
int main()
{
while(scanf("%d",&n)!=EOF)
{
for(int i = 0; i <= 30000;i++) { t[i] = 0; }
int ts,te,maxx = 0;
for(int i = 1; i <= n; i++)
{
scanf("%d%d",&ts,&te);
t[te] = max(t[te],ts);
maxx = max(maxx,te);
}
dp[0] = 0;
for(int i = 1; i <= maxx; i++)
{
dp[i] = dp[i-1];
if(t[i] != 0)
dp[i] = max(dp[i],dp[t[i]-1]+1);
}
printf("%d\n",dp[maxx]);
}
return 0;
}
Obviously, simultaneous work of several sections is necessary in order to reduce the time for scientific program of the conference and to have more time for the banquet, tea-drinking, and informal discussions. However, it is
possible that interesting reports are given simultaneously at different sections.
A participant has written out the time-table of all the reports which are interesting for him. He asks you to determine the maximal number of reports he will be able to attend.
题目好多词都看不懂 我是英语渣渣 , 于是求助与愚蠢的翻译软件。 果然翻译软件是愚蠢的。
然而,通过努力我自己看懂了。
对于每一个时间,当前时间的最大可以参加的会议数 取前一个时间的值 和当前时间结束的最后一个会议的 开始时间的前一个时间的会议数+1 ,取两者间的大值。 嗯, 果然我也没看懂我在说什 , 上方程
dp[i] = max( dp[i-1] , dp[ t[i] - 1] + 1)
如果在 第i时刻没参加会议或会议还没结束 那么参加的会议数应该和前一时刻相等。 如果该时刻有个会议结束了 ,那么这个时刻的会议数应该是会议开始前的 前一时刻会议数+1。
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 30100
int dp
;
int t
;
int n;
int main()
{
while(scanf("%d",&n)!=EOF)
{
for(int i = 0; i <= 30000;i++) { t[i] = 0; }
int ts,te,maxx = 0;
for(int i = 1; i <= n; i++)
{
scanf("%d%d",&ts,&te);
t[te] = max(t[te],ts);
maxx = max(maxx,te);
}
dp[0] = 0;
for(int i = 1; i <= maxx; i++)
{
dp[i] = dp[i-1];
if(t[i] != 0)
dp[i] = max(dp[i],dp[t[i]-1]+1);
}
printf("%d\n",dp[maxx]);
}
return 0;
}
相关文章推荐
- jquery validate 详解
- jQuery UI设置固定日期选择特效代码分享
- JsonLib 简单入门
- 树莓派安装pidora (Fedora Remix)详细教程 及一系列设置
- CDH5.4.5离线分布式安装,角色及目录参考
- 《HTML5从入门到精通》中文学习教程
- js实现的早期滑动门菜单效果代码
- 积跬步,聚小流------实例分析jquery开发插件两种方法的区别
- 清除HtmlAgilityPack得到的InnerText中残留的script
- jquery网页加载进度条NProgress.js
- js判断是不是ie,浏览器的类型
- #与javascript:void(0)的区别
- 常用CSS书写技巧和CSS HACK技巧
- mysql update时报错You are using safe update mode
- javascript -- 原型对象
- C# json 一维数组 和 二维数组的转换
- C# json 一维数组 和 二维数组的转换
- css网页自适应-2
- css网页自适应-1
- jQuery实现自动与手动切换的滚动新闻特效代码分享