Submission #335937

#TimeUsernameProblemLanguageResultExecution timeMemory
335937aryan12Exhibition (JOI19_ho_t2)C++17
100 / 100
67 ms5740 KiB
#include <bits/stdc++.h> using namespace std; bool cmp(pair<long long, long long> a, pair<long long, long long> b) { if(a.second == b.second) return a.first < b.first; return a.second < b.second; } void Solve() { long long n, m; cin >> n >> m; vector<pair<long long, long long> > pictures(n + 1); vector<long long> frames(m + 1); for(long long i = 1; i <= n; i++) { cin >> pictures[i].first >> pictures[i].second; } for(long long i = 1; i <= m; i++) { cin >> frames[i]; } sort(pictures.begin() + 1, pictures.begin() + 1 + n, cmp); sort(frames.begin() + 1, frames.begin() + 1 + m); /*cout << "Sorting of pictures was as follows" << endl; for(long long i = 1; i <= n; i++) { cout << pictures[i].first << " " << pictures[i].second << endl; } cout << "Sorting of frames was as follows" << endl; for(long long i = 1; i <= m; i++) { cout << frames[i] << " "; } cout << endl;*/ long long curAns = 0, curPic = n; for(long long i = m; i > 0; i--) { if(curPic <= 0) break; while(curPic > 0 && pictures[curPic].first > frames[i]) { curPic--; } if(curPic > 0) { curPic--; curAns++; } } cout << curAns << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); Solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...