1 条题解

  • 0
    @ 2023-5-16 17:56:00
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int n, t[100005], len, pos;
    struct mouse
    {
        int w, v;
    } m[100005];
    bool cmp(mouse a, mouse b)
    {
        if (a.v != b.v) return a.v>b.v;
        else return a.w > b.w;
    }
    int main()
    {
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> m[i].w >> m[i].v;
        sort(m + 1, m + 1 + n, cmp);
        len = 1;
        t[1] = m[1].w;
        for (int i = 2; i <= n; i++)
        {
            if (m[i].w > t[len])
                t[++len] = m[i].w;
            else
            {
                pos = lower_bound(t + 1, t + len + 1, m[i].w) - t;
                t[pos] = m[i].w;
            }
        }
        cout << len;
        return 0;
    }
    

    信息

    ID
    74
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    (无)
    递交数
    29
    已通过
    2
    上传者