zoukankan      html  css  js  c++  java
  • 8.5-Day1T3--Asm.Def 的一秒

    题目大意

    略...

    (吐槽这题面...让我毫无阅读兴趣)

    题解

    首先要求出在以两条斜线为新坐标轴下,每个点的坐标

    那么....按x先排序

    再求y的最长上升子序列

    复杂度O(nlogn)吧

    记得开longlong

    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #define ll long long
    using namespace std;
    inline ll read()
    {
        ll sum = 0,p = 1;
        char ch = getchar();
        while(ch < '0' || ch > '9')
        {
            if(ch == '-')
                p = -1;
            ch = getchar();
        }
        while(ch >= '0' && ch <= '9')
        {
            (sum *= 10) += ch - '0';
            ch = getchar();
        }
        return sum * p;
    }
    const int maxn = 100005;
    ll n,a,b,c,d,f[maxn];
    struct pot
    {
        ll x,y;
    }p[maxn];
    bool cmp(pot a,pot b){return a.x < b.x;}
    ll lis()
    {
        ll len = 0;
        for(int i = 1;i <= n;i++)
            if(p[i].x > 0 && p[i].y > 0)
            {
                if(p[i].y > f[len])
                    f[++len] = p[i].y;
                else
                if(p[i].y< f[1])
                    f[1] = p[i].y;
                else
                    f[lower_bound(f + 1,f + len + 1,p[i].y) - f] = p[i].y;
            }
            return len;
    }
    int main()
    {
        n = read();
        a = read(),b = read(),c = read(),d = read();
        for(int i = 1;i <= n;i++)
        {
            int x = read(),y = read();
            p[i].x = c * x - d * y;
            p[i].y = b * y - a * x;
        }
        sort(p+1,p + n + 1,cmp);
        printf("%lld",lis());
        return 0;
    }
    View Code
  • 相关阅读:
    Mybatis入门
    Spring的xml文件配置方式实现AOP
    jquery简直是太酷炫强大了
    [Google Guava] 2.2-新集合类型
    小规模的流处理框架.Part 1: thread pools
    数据库三大范式和五大约束
    Hibernate:缓存
    MyBatis:缓存配置
    Python:协程
    微信公众号开发之测试账号
  • 原文地址:https://www.cnblogs.com/darlingroot/p/11304011.html
Copyright © 2011-2022 走看看