Submission #335618

#TimeUsernameProblemLanguageResultExecution timeMemory
335618JoshcJust Long Neckties (JOI20_ho_t1)C++11
100 / 100
135 ms17620 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; #define ll long long ll x[200002], y[200002], ans[200002], c; int main() { int n; vector<pair<ll, ll> > a; vector<ll> b; scanf("%d", &n); for (int i=0; i<=n; i++) { scanf("%lld", &c); a.emplace_back(c, i); } sort(a.begin(), a.end()); for (int i=0; i<n; i++) { scanf("%lld", &c); b.push_back(c); } sort(b.begin(), b.end()); for (int i=1; i<=n; i++) { x[i] = max(a[i-1].first-b[i-1], x[i-1]); y[i] = max(a[n-i+1].first-b[n-i], y[i-1]); } for (int i=0; i<=n; i++) ans[a[i].second] = max(x[i], y[n-i]); for (int i=0; i<=n; i++) printf("%lld ", ans[i]); }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
ho_t1.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |         scanf("%lld", &c);
      |         ~~~~~^~~~~~~~~~~~
ho_t1.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |         scanf("%lld", &c);
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...