Submission #481197

# Submission time Handle Problem Language Result Execution time Memory
481197 2021-10-19T18:58:19 Z Lobo Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
 
using namespace std;

const long long INFll = (long long) 1e18 + 10;
const int INFii = (int) 1e9 + 10;
typedef long long ll;
typedef int ii;
typedef long double dbl;
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 100010

ii n, m, bit[maxn];
pair<ii,ii> p[maxn];

void att(ii pos, ii val) {
    for(ii i = pos; i <= m; i+= i&-i) {
        bit[i] = max(bit[i],val);
    }
}

ii query(ii pos) {
    ii ans = 0;
    for(ii i = pos; i > 0; i-= i&-i) {
        ans = max(ans, bit[i]);
    }

    return ans;
}

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

    //freopen("in.in", "r", stdin);
    //freopen("out.out", "w", stdout);

    cin >> n >> m;

    for(ii i = 1; i <= n; i++) {
        cin >> p[i].sc >> p[i].fr;
    }

    vector<ii> c;
    for(ii i = 1; i <= m; i++) {
        ii x;cin >> x;
        c.pb(x);
    }
    c.pb(INFii);

    sort(p+1,p+1+n);
    sort(all(c));

    priority_queue<pair<ii,ii>> q;
    for(ii i = 1; i <= n; i++) {
        ii x = lower_bound(all(c),p[i].sc)-c.begin()+1;
        ii qrr = query(x-1)+1;
        att(x,qrr);

        while(q.size() > 0 && x <= q.top().fr) {
            att(q.top().fr,q.top().sc);
            auto aux = q.top();
            q.pop();
            if(aux.fr+1 <= m) q.push(mp(aux.fr+1,aux.sc+1));
        }

        if(x+1 <= m) q.push(mp(x+1,qrr+1));


    }

    cout << query(m) << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Incorrect 0 ms 204 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Incorrect 0 ms 204 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Incorrect 0 ms 204 KB Output isn't correct
11 Halted 0 ms 0 KB -