Submission #540496

#TimeUsernameProblemLanguageResultExecution timeMemory
540496krit3379Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
233 ms18564 KiB
#include<bits/stdc++.h> using namespace std; #define N 200005 int b[N],ans[N]; pair<int,int> a[N]; multiset<int> s; int main(){ int n,i; 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++)s.insert(-max(a[i].first-b[i],0)); ans[a[n+1].second]=-*s.begin(); for(i=n;i>0;i--){ s.erase(-max(a[i].first-b[i],0)); s.insert(-max(a[i+1].first-b[i],0)); ans[a[i].second]=-*s.begin(); } for(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:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
ho_t1.cpp:12:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for(i=1;i<=n+1;i++)scanf("%d",&a[i].first),a[i].second=i;
      |                        ~~~~~^~~~~~~~~~~~~~~~~~
ho_t1.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     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...