Codeforces 249D Donkey and Stars (线段树+扫描线)
来源:互联网 发布:杭州行知小学两个校区 编辑:程序博客网 时间:2024/05/16 15:25
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <vector>#include <queue>#include <map>#include <set>#include <algorithm>#include <ctime>#include <cstdlib>#include <functional>#pragma comment(linker,"/STACK:102400000,102400000")using namespace std;#define eps 1e-10#define N 300030#define B 20#define M 3000020#define inf 0x3f3f3f3f#define LL long long#define pii pair<int, int>#define MP make_pair#define fi first#define se second#define mod 1000000007#define ls (i << 1)#define rs (ls | 1)#define md (ll + rr >> 1)#define lson ll, md, ls#define rson md + 1, rr, rsint n, a, b, c, d;LL san[N], cnt;int dp[N];struct node {int x, y;bool operator < (const node &t) const {LL u = 1LL * c * x - 1LL * d * y;LL v = 1LL * c * t.x - 1LL * d * t.y;if(u != v) return u > v;return 1LL * a * x - 1LL * b * y > 1LL * a * t.x - 1LL * b * t.y;}}p[N];int mx[N];void upd(int x, int v) {while(x <= cnt) {mx[x] = max(mx[x], v);x += x & -x;}}int query(int x) {int ret = 0;while(x) {ret = max(ret, mx[x]);x -= x & -x;}return ret;}int haxi(LL x) {return lower_bound(san + 1, san + cnt + 1, x) - san;}int main() {scanf("%d", &n);scanf("%d/%d%d/%d", &a, &b, &c, &d);for(int i = 1; i <= n; ++i) {scanf("%d%d", &p[i].x, &p[i].y);san[++cnt] = 1LL * a * p[i].x - 1LL * b * p[i].y;}n++; p[n].x = 0, p[n].y = 0;san[++cnt] = 0;sort(p + 1, p + n + 1);sort(san + 1, san + cnt + 1);cnt = unique(san + 1, san + cnt + 1) - san - 1;for(int i = 1; i <= n; ++i) {LL tmp = 1LL * a * p[i].x - 1LL * b * p[i].y;int pp = haxi(tmp);dp[i] = query(pp - 1) + 1;upd(pp, dp[i]);}for(int i = 1; i <= n; ++i) {if(p[i].x == 0 && p[i].y == 0) {printf("%d\n", dp[i] - 1);break;}}return 0;}
0 0
- Codeforces 249D Donkey and Stars (线段树+扫描线)
- 【Codeforces249D】Donkey and Stars
- Codeforces 610D Vika and Segments 【线段树扫描线 求面积并】
- CodeForces 610 D.Vika and Segments(线段树+扫描线)
- poj 1151 Atlantis && codeforces #337 D. Vika and Segments (线段树+扫描线)(求面积并)
- POJ_2482 Stars in Your Window 扫描线 + 线段树
- poj 2482 Stars in Your Window(线段树+扫描线)
- poj 2482 Stars in Your Window(线段树+扫描线)
- poj 2482 Stars in Your Window(线段树,扫描线)
- 【POJ】2482 Stars in Your Window 线段树 + 扫描线
- POJ 2482 Stars in Your Window(线段树扫描线)
- POJ 2482 Stars in Your Window (线段树扫描线)
- poj 2482 Stars in Your Window 线段树 扫描线
- POJ 2482 Stars in Your Window 线段树+扫描线
- POJ 2482(Stars in Your Window-线段树+扫描线)
- poj 2482 Stars in Your Window 扫描线 线段树
- 【poj2482】Stars in Your Window (扫描线+线段树)
- POJ 2482 Stars in Your Window(线段树扫描线)
- 【git】忽略无用的文件
- Ubuntu 14.04 关闭触摸板以及杀死终端命令
- Yii中直接使用sql
- Swift_ uitableview使用自定义(xib)cell
- 大众点评支付渠道网关系统的实践之路
- Codeforces 249D Donkey and Stars (线段树+扫描线)
- 在CTreeCtrl中捕获复选框选中消息,父子节点选中状态联动
- iOS的Demo上传到github上
- MQ比较,kafka消息队列
- JAVA集合概述
- 如何选择开源项目?
- Linux系统命令行查看硬件配置(ubuntu)
- 信息熵 条件熵 信息增益 信息增益比 GINI系数
- K-means聚类算法原理简单介绍