Submission #329873

#TimeUsernameProblemLanguageResultExecution timeMemory
329873arnold518Worst Reporter 2 (JOI16_worst_reporter2)C++14
60 / 100
2076 ms25564 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 4e5; int N; pii _A[MAXN+10]; int A[MAXN+10]; int B[MAXN+10]; vector<int> V[MAXN+10]; int main() { scanf("%d", &N); for(int i=1; i<=N; i++) scanf("%d%d", &_A[i].second, &_A[i].first), _A[i].second*=-1; for(int i=1; i<=N; i++) scanf("%d%d", &_A[i+N].second, &_A[i+N].first); N*=2; sort(_A+1, _A+N+1); for(int i=1; i<=N; i++) A[i]=_A[i].second; for(int i=1; i<=N; i++) { if(A[i]<0) B[i]=B[i-1]+1; else B[i]=B[i-1]-1; } int ans=N/2; for(int i=1; i<=N; i++) { if(A[i]<0) { V[-A[i]].push_back(i); } else { if(V[A[i]].empty()) continue; bool flag=true; for(int j=V[A[i]].back(); j<i; j++) { if(B[j]<1) flag=false; } if(!flag) { V[A[i]].clear(); } else { for(int j=V[A[i]].back(); j<i; j++) { B[j]--; } V[A[i]].pop_back(); ans--; } } } printf("%d\n", ans); }

Compilation message (stderr)

worst_reporter2.cpp: In function 'int main()':
worst_reporter2.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
worst_reporter2.cpp:20:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  for(int i=1; i<=N; i++) scanf("%d%d", &_A[i].second, &_A[i].first), _A[i].second*=-1;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
worst_reporter2.cpp:21:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  for(int i=1; i<=N; i++) scanf("%d%d", &_A[i+N].second, &_A[i+N].first);
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...