Submission #227174

#TimeUsernameProblemLanguageResultExecution timeMemory
227174ho94949Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
145 ms7400 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 200'000; pair<int, int> A[MAXN+1]; int B[MAXN]; int N; int main() { scanf("%d", &N); for(int i=0; i<N+1; ++i) { scanf("%d", &A[i].first); A[i].second = i; } for(int i=0; i<N; ++i) scanf("%d", B+i); sort(A, A+N+1); sort(B, B+N); vector<int> p(1), q(1); for(int i=0; i<N; ++i) p.push_back(max(p.back(),A[i].first-B[i])); for(int i=N-1; i>=0; --i) q.push_back(max(q.back(),A[i+1].first-B[i])); reverse(q.begin(), q.end()); vector<int> ans(N+1); for(int i=0; i<=N; ++i) ans[A[i].second] = max(p[i], q[i]); for(int i=0; i<=N; ++i) printf("%d ", ans[i]); puts(""); }

Compilation message (stderr)

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