# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
553278 | sandry24 | Exhibition (JOI19_ho_t2) | C++17 | 1 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
void solve(){
ll n, m;
cin >> n >> m;
vector<pair<ll, ll>> pict(n);
vector<ll> frames(m);
for(int i = 0; i < n; i++)
cin >> pict[i].f >> pict[i].s;
for(int i = 0; i < m; i++)
cin >> frames[i];
sort(frames.begin(), frames.end());
sort(pict.begin(), pict.end());
multiset<ll> lot;
int j = 0;
ll last = -1;
ll occurences = 0;
ll ans = 0, current = 0;
for(int i = 0; i < m; i++){
while(pict[j].f <= frames[i]){
lot.insert(pict[j].s);
j++;
}
if(lot.size() == 0)
continue;
//cout << lot.size() << '\n';
ll lb = last;
if(occurences > lot.count(lb) && lb != -1)
lb++;
//cout << lb << ' ';
auto h = lot.lower_bound(lb);
if(h == lot.end()){
ans = max(current, ans);
last = -1;
h = lot.lower_bound(last);
current = 0;
}
if(*h == lb)
occurences++;
else
occurences = 1;
last = *h;
//cout << lb << ' ' << last << '\n';
current++;
}
ans = max(current, ans);
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |