Submission #286862

#TimeUsernameProblemLanguageResultExecution timeMemory
286862arnold518Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
169 ms10872 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 = 2e5; int N, B[MAXN+10]; pii A[MAXN+10]; int ans[MAXN+10]; int P[MAXN+10], Q[MAXN+10]; int main() { scanf("%d", &N); for(int i=1; i<=N+1; i++) scanf("%d", &A[i].first), A[i].second=i; for(int i=1; i<=N; i++) scanf("%d", &B[i]); sort(A+1, A+N+2); sort(B+1, B+N+1); for(int i=1; i<=N; i++) P[i]=max(P[i-1], A[i].first-B[i]); for(int i=N; i>=1; i--) Q[i]=max(Q[i+1], A[i+1].first-B[i]); for(int i=1; i<=N+1; i++) ans[A[i].second]=max(P[i-1], Q[i]); for(int i=1; i<=N+1; i++) printf("%d ", ans[i]); }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
ho_t1.cpp:19:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  for(int i=1; i<=N+1; i++) scanf("%d", &A[i].first), A[i].second=i;
      |                            ~~~~~^~~~~~~~~~~~~~~~~~~
ho_t1.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", &B[i]);
      |                          ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...