题目1463:招聘会
-
题目描述:
-
又到毕业季,很多大公司来学校招聘,招聘会分散在不同时间段,小明想知道自己最多能完整的参加多少个招聘会(参加一个招聘会的时候不能中断或离开)。
-
输入:
-
第一行n,有n个招聘会,接下来n行每行两个整数表示起止时间,由从招聘会第一天0点开始的小时数表示。
n <= 1000 。
-
输出:
-
最多参加的招聘会个数。
-
样例输入:
-
3 9 10 10 20 8 15
-
样例输出:
-
2
算法分析
普通背包问题
题目1364:v字仇杀队
题目1462:两船载物问题
题目1455:珍惜现在,感恩生活
题目1209:最小邮票数
题目1420:Jobdu MM分水果
项目安排类题目
题目1499:项目安排
题目1463:招聘会
题目1434:今年暑假不AC
资源无限求最大值的题目。
题目1494:Dota
源程序
//============================================================================
// Name : judo1434.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
struct TVshow{
int begt;
int endt;
};
std::vector<TVshow> tvs;
bool lessthan(const TVshow & tsl,const TVshow &tsr){
return tsl.endt < tsr.endt;
}
void noAC(int n){
TVshow ts;
tvs.clear();
for(int i = 0;i<n;i++){
std::cin>>ts.begt>>ts.endt;
tvs.push_back(ts);
}
std::sort(tvs.begin(),tvs.end(),lessthan);
int endtime = tvs.back().endt;
int *maxn = new int[endtime+1];
for(int i = 0;i<endtime+1;i++)
maxn[i]=0;
for(int i = 0;i<n;i++){
int temMaxn = std::max(maxn[tvs.at(i).endt],maxn[tvs.at(i).begt]+1);
for(int j = tvs.at(i).endt; j<endtime+1; j++){
//maxn[j] = temMaxn;
maxn[j] = std::max(maxn[j],temMaxn);
}
}
std::cout<<maxn[endtime]<<std::endl;
}
int main() {
//cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
int n;
while(std::cin>>n && n!=0){
noAC(n);
}
return 0;
}
/**************************************************************
Problem: 1463
User: KES
Language: C++
Result: Accepted
Time:10 ms
Memory:1520 kb
****************************************************************/
普通背包问题
题目1364:v字仇杀队
题目1462:两船载物问题
题目1455:珍惜现在,感恩生活
题目1209:最小邮票数
题目1420:Jobdu MM分水果
项目安排类题目
题目1499:项目安排
题目1463:招聘会
题目1434:今年暑假不AC
资源无限求最大值的题目。
题目1494:Dota