Submission #201271

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

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:17:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
ho_t1.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
ho_t1.cpp:20:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N+1; i++) scanf("%d", &A[i].first), A[i].second=i;
                        ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
ho_t1.cpp:21:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(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...