Submission #394596

#TimeUsernameProblemLanguageResultExecution timeMemory
394596benedict0724Exhibition (JOI19_ho_t2)C++17
100 / 100
83 ms4476 KiB
#include <bits/stdc++.h> using namespace std; pair<int, int> SV[100002]; int C[100002]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int N, M; cin >> N >> M; for(int i=1;i<=N;i++) { cin >> SV[i].second >> SV[i].first; } for(int i=1;i<=M;i++) { cin >> C[i]; } sort(SV + 1, SV + N + 1); sort(C + 1, C + M + 1); int cnt = 0; for(int i=1;i<=N;i++) { int l = 1, r = M+1; while(l < r) { int mid = (l + r)/2; if(SV[i].second <= C[mid]) r = mid; else l = mid + 1; } SV[i].second = l; } /* for(int i=1;i<=N;i++) { cout << SV[i].second << "\n"; } */ int l = 1, r = M+1; while(l < r) { int mid = (l + r)/2; int now = mid; for(int i=1;i<=N;i++) { if(now == M+1) break; if(SV[i].second <= now) now++; } if(now == M+1) r = mid; else l = mid + 1; } cout << M + 1 - l; }

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:24:9: warning: unused variable 'cnt' [-Wunused-variable]
   24 |     int cnt = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...