Submission #233708

#TimeUsernameProblemLanguageResultExecution timeMemory
233708dualityJust Long Neckties (JOI20_ho_t1)C++11
100 / 100
139 ms10104 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back typedef long long int LLI; typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pii> vpii; pii A[200001]; int B[200000],C[200001],ans[200001]; int main() { int i; int N; scanf("%d",&N); for (i = 0; i <= N; i++) scanf("%d",&A[i].first),A[i].second = i; for (i = 0; i < N; i++) scanf("%d",&B[i]); sort(A,A+N+1),sort(B,B+N); int m = 0; for (i = 0; i <= N; i++) { C[i] = max(C[i],m); if (i < N) m = max(m,A[i].first-B[i]); } m = 0; for (i = N; i >= 0; i--) { C[i] = max(C[i],m); if (i > 0) m = max(m,A[i].first-B[i-1]); } for (i = 0; i <= N; i++) ans[A[i].second] = C[i]; for (i = 0; i <= N; i++) printf("%d ",ans[i]); printf("\n"); return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
ho_t1.cpp:16:53: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i <= N; i++) scanf("%d",&A[i].first),A[i].second = i;
                              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
ho_t1.cpp:17:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; 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...