记录编号 206114 评测结果 AAAAAAAAAA
题目名称 [SYOI 2015] Asm.Def的一秒 最终得分 100
用户昵称 Gravatarppfish 是否通过 通过
代码语言 C++ 运行时间 0.282 s
提交时间 2015-11-06 01:04:51 内存使用 2.69 MiB
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

template<class T>inline void Read(T &x)
{
    int f = 1;
    char t = getchar();
    while (t < '0' || t > '9') {
        if (t == '-') f = -1;
        t = getchar();
    }
    x = 0;
    while (t >= '0' && t <= '9') {
        x = x * 10 + t - '0';
        t = getchar();
    }
    x *= f;
}

const int maxn = 101005;

struct point {
    long long x, y;
    bool operator == (const point &rhs) const { return x == rhs.x && y == rhs.y; }
    bool operator < (const point &rhs) const {
        return x < rhs.x || (x == rhs.x && y > rhs.y);
    }
};

int n;
long long a, b, c, d;
long long yl[maxn];
int mx[maxn], ln;
point p[maxn];

void update(int x, int v)
{
    while (x <= ln) {
        mx[x] = max(mx[x], v);
        x += x & (-x);
    }
}

int query(int x)
{
    int re = 0;
    while (x > 0) {
        re = max(re, mx[x]);
        x -= x & (-x);
    }
    return re;
}

void input()
{
    long long x, y;
    int en = 0;
    Read(n), Read(a), Read(b), Read(c), Read(d);
    for (register int i = 1; i <= n; i++) {
        Read(x), Read(y);
        p[i].x = 1ll * c * x - 1ll * d * y;
        p[i].y = 1ll * b * y - 1ll * a * x;
    }
    for (register int i = 1; i <= n; i++) {
        if (p[i].x > 0 && p[i].y > 0) {
            p[++en] = p[i];
            yl[++ln] = p[i].y;
        }
    }
    yl[++ln] = 0;
    n = en;
}

void solve()
{
    int ans = 0, id, re;
    
    sort(p + 1, p + n + 1);    
    sort(yl + 1, yl + ln + 1);
    
    ln = unique(yl + 1, yl + ln + 1) - yl + 1;
    update(1, 1);
    
    for (register int i = 1; i <= n; i++) {
        re = query(lower_bound(yl + 1, yl + ln + 1, p[i].y) - yl - 1);
        ans = max(ans, re + 1);
        update(lower_bound(yl + 1, yl + ln + 1, p[i].y) - yl, re + 1);
    }

    printf("%d\n", ans - 1);
}

int main()
{
    //#ifndef ONLINE_JUDGE
    freopen("asm_second.in", "r", stdin);
    freopen("asm_second.out", "w", stdout);
    //#endif

    input();
    solve();

#ifndef ONLINE_JUDGE
    fclose(stdin);
    fclose(stdout);
#endif
    return 0;
}