Submission #485144

# Submission time Handle Problem Language Result Execution time Memory
485144 2021-11-06T10:38:22 Z ak2006 Exhibition (JOI19_ho_t2) C++14
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
const ll mod = 1e9 + 7,inf = 1e18;
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void setIO()
{
    fast;
}
bool cmp1(vi&f,vi&s)
{
    return f[1] >= s[1];
}
bool cmp2(int f,int s)
{
    return f >= s;
}
int main()
{
    setIO();
    int n,m;
    cin>>n>>m;
    vvi a(n,vi(2));
    for (int i = 0;i<n;i++)
        cin>>a[i][0]>>a[i][1];

    vi s(m);
    for (int i = 0;i<m;i++)cin>>s[i];
    
    //s[i + 1] >= s[i] and a[i + 1][1] >= a[i][1] and 
    //a[i][0] <= s[i]
    
    sort(a.begin(),a.end(),cmp1);
    sort(s.begin(),s.end(),cmp2);
    
    //hence s[i + 1] >= s[i] and a[pos + 1][1] >= a[pos][1]
    //hence we only need to ensure a[pos][0] <= s[i]
    
    int pos = 0;
    int ans = 0;
    for (int sz:s){
        while (pos < n and !(a[pos][0] <= sz))pos++;
        if (pos < n)
            ans++;
        pos++;
    }
    cout<<ans<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -