Submission #1237143

#TimeUsernameProblemLanguageResultExecution timeMemory
1237143GeforgsExhibition (JOI19_ho_t2)C++20
0 / 100
0 ms328 KiB
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <queue> #include <map> #include <unordered_map> #include <stack> #include <bitset> #include <string> #include <cstring> #include <iterator> #include <random> #define ll long long #define ld long double #define inf (ll)(2*1e18) #define sort(a) sort(a.begin(), a.end()) #define reverse(a) reverse(a.begin(), a.end()) #define pb push_back #define endl "\n" using namespace std; void solve(){ ll n, m, i, x, pos; cin>>n>>m; vector<pair<ll, ll>> a(n); vector<ll> b(m); vector<ll> c; vector<ll> d; for(i=0;i<n;++i){ cin>>a[i].second>>a[i].first; } for(i=0;i<m;++i){ cin>>b[i]; } sort(a); sort(b); c.pb(0); d.pb(0); for(i=0;i<n;++i){ auto it = lower_bound(c.begin(), c.end(), a[i].second); if(*it == a[i].first) ++it; if(it == c.end()){ x = d.back(); auto it2 = lower_bound(b.begin()+x, b.end(), a[i].second); if(it2 == b.end()) continue; c.pb(a[i].second); d.pb(it2 - b.begin() + 1); }else{ pos = it - c.begin(); x = d[pos-1]; auto it2 = lower_bound(b.begin()+x, b.end(), a[i].second); if(it2 == b.end()) continue; c[pos] = a[i].second; d[pos] = it2 - b.begin() + 1; } } cout<<c.size() - 1<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); srand(time(nullptr)); ll t=1; // cin>>t; for(;t>0;--t){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...