Submission #540749

# Submission time Handle Problem Language Result Execution time Memory
540749 2022-03-21T16:07:20 Z status_coding Exhibition (JOI19_ho_t2) C++14
50 / 100
1000 ms 1788 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("unroll-loops")

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)
{
    for(int i=n;i>=0;i--)
        if(dp[i] <= val)
            return i;

    return n+1;
    /*
    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)
{
    for(int i=1;i<=m;i++)
        if(s[i] >= val)
            return i;

    return m+1;

    /*
    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 sId = cbS(v[i].s);

        for(int j=n-1;j>=0;j--)
        {
            int nsId = max(sId, dp[j]+1);

            if(nsId <= m)
                dp[j+1] = min(dp[j+1], nsId);
        }

        /*
        for(int j=0;j<=n;j++)
            cout<<dp[j]<<' ';
        cout<<'\n';
        */
    }

    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 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 3 ms 212 KB Output is correct
24 Correct 3 ms 212 KB Output is correct
25 Correct 3 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 2 ms 308 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 3 ms 212 KB Output is correct
30 Correct 3 ms 212 KB Output is correct
31 Correct 3 ms 212 KB Output is correct
32 Correct 2 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 2 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 3 ms 332 KB Output is correct
37 Correct 3 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 3 ms 212 KB Output is correct
24 Correct 3 ms 212 KB Output is correct
25 Correct 3 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 2 ms 308 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 3 ms 212 KB Output is correct
30 Correct 3 ms 212 KB Output is correct
31 Correct 3 ms 212 KB Output is correct
32 Correct 2 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 2 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 3 ms 332 KB Output is correct
37 Correct 3 ms 212 KB Output is correct
38 Execution timed out 1082 ms 1788 KB Time limit exceeded
39 Halted 0 ms 0 KB -