Submission #365216

#TimeUsernameProblemLanguageResultExecution timeMemory
365216jazzupJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
181 ms6276 KiB
#include<cstdio> #include<algorithm> using namespace std; int a[200010],aa[200010],b[200010],dp1[200010],dp2[200010]; int main(){ int n; scanf("%d",&n); for(int i=0;i<=n;i++){ scanf("%d",&aa[i]); a[i]=aa[i]; } sort(a,a+n+1); for(int i=0;i<n;i++){ scanf("%d",&b[i]); } sort(b,b+n); dp1[0]=max(a[0]-b[0],0); for(int i=1;i<n;i++){ dp1[i]=max(dp1[i-1],max(a[i]-b[i],0)); } dp2[n-1]=max(a[n]-b[n-1],0); for(int i=n-2;i>=0;i--){ dp2[i]=max(dp2[i+1],max(a[i+1]-b[i],0)); } for(int i=0;i<=n;i++){ int *p=lower_bound(a,a+n+1,aa[i]); int x=p-a; printf("%d ",max(dp1[x-1],dp2[x])); } // for(int i=0;i<n;i++){ // printf("%d ",dp1[i]); // } // printf("\n"); // for(int i=0;i<n;i++){ // printf("%d ",dp2[i]); // } return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
ho_t1.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   scanf("%d",&aa[i]);
      |   ~~~~~^~~~~~~~~~~~~
ho_t1.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |   scanf("%d",&b[i]);
      |   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...