Submission #788514

# Submission time Handle Problem Language Result Execution time Memory
788514 2023-07-20T10:06:24 Z mpawicka_77 Exhibition (JOI19_ho_t2) C++14
0 / 100
1 ms 308 KB
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+3;
int nr[N],M[N];
pair<int,int>T[N];
int n,m;
int bs(int x,int dl)
{
    int pocz=0,kon=dl+1;
    while(pocz+1<kon)
    {
        int mid=(pocz+kon)/2;
        if(nr[mid]>x)kon=mid;
        else pocz=mid;
    }
    return kon;
}
bool f(int x)
{
    for(int i=0;i<=n;i++)nr[i]=2*1e9;
    int Maks=0;
    for(int i=1;i<=n;i++)
    {
        int Ind=bs(T[i].second,Maks);
        if(T[i].second>M[Ind+x])continue;
        nr[Ind]=min(T[i].second,nr[Ind]);
        Maks=max(Maks,Ind);
        if(Maks+x==m)return true;
    }
    return false;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>T[i].second>>T[i].first;
    }
    sort(T+1,T+n+1);
    for(int i=1;i<=m;i++)cin>>M[i];
    sort(M+1,M+m+1);
    int pocz=0,kon=min(m,n)+1;
    while(pocz+1<kon)
    {
        int mid=(pocz+kon)/2;
        if(f(m-mid))pocz=mid;
        else kon=mid;
    }
    cout<<pocz;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -