Submission #166089

# Submission time Handle Problem Language Result Execution time Memory
166089 2019-11-30T15:51:19 Z davooddkareshki Exhibition (JOI19_ho_t2) C++17
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define F first
#define S second

const int maxn = 1e5+10;
const int mod = 1e9+7;

int n, m;
vector<pair<int,int>> v;
int s[maxn];

bool ok(int k)
{
    if(k > n || k > m) return 0;

    vector<pair<int,int>> ve;
    for(int i = 0; i < k; i++)
        ve.push_back({v[i].S,v[i].F});
    sort(ve.begin(),ve.end());
    vector<int> v1;
    for(int i = m-k; i < m; i++)
        v1.push_back(s[i]);

    for(int i = 0; i < k; i++)
        if(ve[i].S > v1[i])
            return 0;
    return 1;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>> n >> m;
    for(int i = 0; i < n; i++){
        int a, b; cin>> a >> b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());

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

    int hi = n+1, lo = 0;
    while(hi-lo > 1)
    {
        int tm = (hi+lo)/2;
        if(ok(tm)) lo = tm;
        else hi = tm;
    }

    cout<< lo;
}



# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Halted 0 ms 0 KB -