Submission #485147

#TimeUsernameProblemLanguageResultExecution timeMemory
485147ak2006Exhibition (JOI19_ho_t2)C++14
100 / 100
61 ms9104 KiB
#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]) || (f[1] == s[1] and f[0] > s[0]); // } // 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][1]>>a[i][0]; 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(),greater<>()); sort(s.begin(),s.end(),greater<>()); //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][1] <= sz))pos++; ans += pos++ < n; } cout<<ans<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...