Submission #540252

# Submission time Handle Problem Language Result Execution time Memory
540252 2022-03-19T18:14:18 Z status_coding Exhibition (JOI19_ho_t2) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

struct pos
{
    int val, s;

    bool operator<(pos b)
    {
        if(val != b.val)
            return val<b.val;
        return s < b.s;
    }
};

int n,m;
pos v[100005];
int s[100005];

int dp[100005];

int cbDp(int val)
{
    int st=0, dr=n, mij, last=n+1;

    while(st <= dr)
    {
        mij = (st+dr)/2;

        if(dp[mij] <= val)
        {
            last=mij;
            st=mij+1;
        }
        else
            dr=mij-1;
    }

    return last;
}

int cbS(int val)
{
    int st=1, dr=m, mij, last=m+1;

    while(st <= dr)
    {
        mij=(st+dr)/2;

        if(s[mij] <= val)
        {
            last=mij;
            dr=mij-1;
        }
        else
            st=mij+1;
    }

    return last;
}

int main()
{
    cin>>n>>m;

    for(int i=1;i<=n;i++)
        cin>>v[i].s>>v[i].val;
    sort(v+1, v+n+1);

    for(int i=1;i<=m;i++)
        cin>>s[i];
    sort(s+1, s+m+1);

    for(int i=1;i<=n;i++)
        dp[i] = 1e9;

    for(int i=1;i<=n;i++)
    {
        if(v[i].s > s[m])
            continue;

        int best = cbDp(v[i].s);

        if(best != n+1)
        {
            int idS = max(dp[best]+1, cbS(v[i].s));

            if(idS != m+1)
                dp[best+1] = min(dp[best+1], idS);
        }
    }

    int ans=0;
    for(int i=1;i<=n;i++)
        if(dp[i] != 1e9)
            ans = max(ans, i);

    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -