hdu 3650 Hot Expo(2010杭州网选题)
来源:互联网 发布:精华液 推荐 知乎 编辑:程序博客网 时间:2024/04/30 13:22
= = 。。。
给你N个活动的开始时间和结束时间,问你几天能看完,每天的同一时刻只能看一个节目。
第一反应是活动安排的那个贪心啊,后来想到类似线段覆盖,只要算出覆盖次数最多的段就好。离散化一下就好了。
A掉后搜题解,有用贪心,有直接模拟的 = = 神呐。。我是算了100*24*3600有可能超时,我才离散化的= =。。居然这么大胆直接模拟了。。
我要是出题人,数据绝对不可能这么水。。。
#include <queue>#include <stack>#include <math.h>#include <stdio.h>#include <stdlib.h>#include <iostream>#include <limits.h>#include <string.h>#include <string>#include <algorithm>using namespace std;const int MAX = 24*3600;const int N = 110;struct NODE {int x,y;};NODE p[N];int a[MAX];int x[N*2];int solve(int cnt,int n){memset(a,0,sizeof(a));for(int i=0; i<n; i++){int xx = lower_bound(x,x+cnt,p[i].x) - x;int yy = lower_bound(x,x+cnt,p[i].y) - x;for(int k=xx; k<=yy; k++)a[k]++;}int mmax = 0;for(int i=0; i<MAX; i++)if( a[i] > mmax )mmax = a[i];return mmax;}int main(){int n;while( ~scanf("%d",&n) && n ){int cnt = 0;for(int i=0; i<n; i++){scanf("%d%d",&p[i].x,&p[i].y);x[cnt++] = p[i].x; x[cnt++] = p[i].y;}sort(x,x+cnt);cnt = unique(x,x+cnt) - x;int ans = solve(cnt, n);printf("%d\n",ans);}return 0;}
- hdu 3650 Hot Expo(2010杭州网选题)
- HDU 3650 Hot Expo
- hdu 3650 Hot Expo
- HDU:3650 Hot Expo
- hdu 3650 Hot Expo(贪心)
- hdu 3650 Hot Expo(TwoPointer)
- hdu 3650 - Hot Expo(贪心)
- HDU 3650 Hot Expo (数据比较小)
- HDU 3650 Hot Expo(气球染色 , 贪心 )
- HDU 3650 Hot Expo(线段覆盖==离散化)
- Hot Expo
- HDU3650 Hot Expo
- hdu 3631 Shortest Path(2010天津网选题)
- HDU 3691 Nubulsa Expo
- HDU 3691 Nubulsa Expo
- hdu 3650 杭州赛水题
- HDU 3691 Nubulsa Expo(SW算法求最小割)
- HDU 3691 Nubulsa Expo(全局最小割Stoer_Wagn)
- Framebuffer,Xorg,directFB,openGL,QT,GTK关系
- 理解Task动作
- 页面间传值的五种方法 - ASP.Net
- 用 Java 实现断点续传 (HTTP)
- 游戏服务器 - Some Concept in Designing Architecture
- hdu 3650 Hot Expo(2010杭州网选题)
- 单片机
- hdu 1003 Max Sum
- SendMessage 和 PostMessage 的区别(转)
- 二进制文件的读写
- ClientOMProxy
- SICP Exercise 3.38
- 游戏服务器 - 数据库异步操作技术 & 数据的保存机制
- Linux Env Tips