Submission #204687

#TimeUsernameProblemLanguageResultExecution timeMemory
204687my99nJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
149 ms7032 KiB
#include<bits/stdc++.h> using namespace std; int b[200100], c[200100], d[200100], ans[200100]; pair<int,int> a[200100]; int main(){ int n; 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++) c[i] = max(a[i].first-b[i], 0), c[i] = max(c[i], c[i-1]); for (int i = n; i >= 1; i--) d[i] = max(a[i+1].first-b[i], 0), d[i] = max(d[i], d[i+1]); for (int i = 1; i <= n+1; i++) ans[a[i].second] = max(c[i-1], d[i]); for (int i = 1; i <= n+1; i++) printf("%d ", ans[i]); return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
ho_t1.cpp:10:60: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n+1; i++) scanf("%d", &a[i].first), a[i].second = i;
                                    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
ho_t1.cpp:11:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     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...