Submission #540748

# Submission time Handle Problem Language Result Execution time Memory
540748 2022-03-21T16:02:11 Z status_coding Exhibition (JOI19_ho_t2) C++14
50 / 100
1000 ms 4740 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)
{
    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;

        for(int j=n-1;j>=0;j--)
        {
            int sId = max(dp[j]+1, cbS(v[i].s));

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

        /*
        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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 194 ms 336 KB Output is correct
21 Correct 192 ms 344 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 9 ms 340 KB Output is correct
24 Correct 99 ms 340 KB Output is correct
25 Correct 105 ms 464 KB Output is correct
26 Correct 119 ms 340 KB Output is correct
27 Correct 2 ms 324 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 3 ms 320 KB Output is correct
30 Correct 185 ms 344 KB Output is correct
31 Correct 202 ms 344 KB Output is correct
32 Correct 2 ms 328 KB Output is correct
33 Correct 1 ms 316 KB Output is correct
34 Correct 67 ms 328 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 190 ms 336 KB Output is correct
37 Correct 207 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 194 ms 336 KB Output is correct
21 Correct 192 ms 344 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 9 ms 340 KB Output is correct
24 Correct 99 ms 340 KB Output is correct
25 Correct 105 ms 464 KB Output is correct
26 Correct 119 ms 340 KB Output is correct
27 Correct 2 ms 324 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 3 ms 320 KB Output is correct
30 Correct 185 ms 344 KB Output is correct
31 Correct 202 ms 344 KB Output is correct
32 Correct 2 ms 328 KB Output is correct
33 Correct 1 ms 316 KB Output is correct
34 Correct 67 ms 328 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 190 ms 336 KB Output is correct
37 Correct 207 ms 352 KB Output is correct
38 Execution timed out 1073 ms 4740 KB Time limit exceeded
39 Halted 0 ms 0 KB -