Submission #100839

#TimeUsernameProblemLanguageResultExecution timeMemory
100839ikura355Exhibition (JOI19_ho_t2)C++14
100 / 100
91 ms4572 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define X first #define Y second const int maxn = 1e5 + 5; const int inf = 2e9; int n,m; pii a[maxn]; int b[maxn]; bool solve(int x) { //printf("solve %d\n",x); int pos = m - x + 1; for(int i=1;i<=n;i++) { if(a[i].X<=b[pos]) pos++; //printf("\t%d %d pos = %d\n",a[i].X,a[i].Y,pos); if(pos == m+1) return 1; } return 0; } int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%d%d",&a[i].X,&a[i].Y); for(int i=1;i<=m;i++) scanf("%d",&b[i]); sort(&a[1],&a[n+1],[&](pii x, pii y){return x.Y!=y.Y ? x.Y<y.Y : x.X<y.X;}); sort(&b[1],&b[m+1]); int l = 1, r = m, mid, ans = 0; while(l<=r) { mid = (l+r)/2; if(solve(mid)) { ans = mid; l = mid+1; } else r = mid-1; } printf("%d",ans); }

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
joi2019_ho_t2.cpp:29:29: 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",&a[i].X,&a[i].Y);
                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:30:29: 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",&b[i]);
                        ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...