Submission #121270

#TimeUsernameProblemLanguageResultExecution timeMemory
121270onjo0127Exhibition (JOI19_ho_t2)C++11
100 / 100
342 ms10328 KiB
#include <bits/stdc++.h> using namespace std; vector<int> T[100009]; int S[100009], V[100009], C[100009]; int main() { int N, M; scanf("%d%d",&N,&M); for(int i=1; i<=N; i++) scanf("%d%d",&S[i],&V[i]); for(int i=1; i<=M; i++) scanf("%d",&C[i]); sort(C+1, C+M+1); for(int i=1; i<=N; i++) { S[i] = lower_bound(C+1, C+M+1, S[i]) - C; if(S[i] <= M) T[S[i]].push_back(i); } int l = 0, r = M; while(l <= r) { bool f = 1; int m = l+r >> 1, p = -1e9; priority_queue<int> pq; for(int i=1; i<=M; i++) { for(auto &it: T[i]) pq.push(-V[it]); if(M-i+1 <= m) { while(pq.size() && p > -pq.top()) pq.pop(); if(pq.size() == 0) {f = 0; break;} p = -pq.top(); pq.pop(); } } if(f) l = m+1; else r = m-1; } printf("%d", l-1); return 0; }

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:19:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = l+r >> 1, p = -1e9;
           ~^~
joi2019_ho_t2.cpp:8:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int N, M; scanf("%d%d",&N,&M);
            ~~~~~^~~~~~~~~~~~~~
joi2019_ho_t2.cpp:9:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=N; i++) scanf("%d%d",&S[i],&V[i]);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:10:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=M; i++) scanf("%d",&C[i]);
                          ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...