Submission #287878

#TimeUsernameProblemLanguageResultExecution timeMemory
287878Bill_00Boxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long pre[10000001],suf[10000001],p[10000001]; long long delivery(int n, int k, int l, int o[]){ for(int i=0;i<n;i++){ p[i+1]=o[i]; } sort(a+1,a+n+1); for(int i=1;i<=k;i++){ pre[i]=2*p[i]; } pre[0]=0,suf[n+1]=0; for(int i=k+1;i<=n;i++){ pre[i]=pre[i-k]+2*p[i]; } for(int i=1;i<=k;i++){ suf[n+1-i]=2*(l-p[n+1-i]); } for(int i=k+1;i<=n;i++){ suf[n+1-i]=suf[n+1-i+k]+2*(l-p[n+1-i]); } long long ans=1e18; for(int i=0;i<=n;i++){ ans=min(ans,pre[i]+suf[i+1]); } for(int i=0;i<=n-k;i++){ ans=min(ans,pre[i]+suf[i+k+1]+l); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:9:7: error: 'a' was not declared in this scope
    9 |  sort(a+1,a+n+1);
      |       ^