Submission #219562

#TimeUsernameProblemLanguageResultExecution timeMemory
219562MKopchevJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
191 ms10876 KiB
#include<bits/stdc++.h> using namespace std; const int nmax=2e5+42; int n,other[nmax]; pair<int,int> inp[nmax]; int pref[nmax],suff[nmax]; int output[nmax]; int main() { scanf("%i",&n); for(int i=1;i<=n+1;i++){scanf("%i",&inp[i]);inp[i].second=i;} for(int i=1;i<=n;i++)scanf("%i",&other[i]); sort(inp+1,inp+n+2); sort(other+1,other+n+1); for(int i=1;i<=n;i++) pref[i]=max(pref[i-1],inp[i].first-other[i]); for(int i=n+1;i>=2;i--) suff[i]=max(suff[i+1],inp[i].first-other[i-1]); for(int i=1;i<=n+1;i++) output[inp[i].second]=max(pref[i-1],suff[i+1]); /* for(int i=1;i<=n;i++)cout<<pref[i]<<" ";cout<<endl; for(int i=1;i<=n+1;i++)cout<<suff[i]<<" ";cout<<endl; */ for(int i=1;i<=n+1;i++) { printf("%i",output[i]); if(i==n+1)printf("\n"); else printf(" "); } return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:13:47: warning: format '%i' expects argument of type 'int*', but argument 2 has type 'std::pair<int, int>*' [-Wformat=]
     for(int i=1;i<=n+1;i++){scanf("%i",&inp[i]);inp[i].second=i;}
                                        ~~~~~~~^
ho_t1.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
ho_t1.cpp:13:34: 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("%i",&inp[i]);inp[i].second=i;}
                             ~~~~~^~~~~~~~~~~~~~
ho_t1.cpp:14:31: 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("%i",&other[i]);
                          ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...