Submission #911003

#TimeUsernameProblemLanguageResultExecution timeMemory
911003oblantisExhibition (JOI19_ho_t2)C++17
100 / 100
448 ms9228 KiB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define all(v) v.begin(), v.end() #define pb push_back #define ss second #define ff first #define vt vector using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair<int, int> pii; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int inf = 1e9; const int mod = 1e9+7; const int maxn = 1e5 + 1; void solve() { int n, m; cin >> n >> m; pii a[n]; for(int i = 0; i < n; i++){ cin >> a[i].ff >> a[i].ss; } sort(a, a + n); int c[m]; for(int i = 0; i < m; i++){ cin >> c[i]; } sort(c, c + m); int l = 0, r = m + 1; while(l + 1 < r){ int mid = l + (r - l) / 2; int xl = 0, prev = 0; multiset<int> ms; bool ok = 1; for(int i = m - mid; i < m; i++){ while(xl < n && a[xl].ff <= c[i])ms.insert(a[xl].ss), xl++; while(!ms.empty() && prev > *ms.begin())ms.erase(ms.begin()); if(ms.empty()){ ok = 0; break; } prev = *ms.begin(); ms.erase(ms.begin()); } if(ok)l = mid; else r = mid; } cout << l; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int times = 1; //cin >> times; for(int i = 1; i <= times; i++) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...