Submission #1005105

#TimeUsernameProblemLanguageResultExecution timeMemory
1005105GrayBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
460 ms372252 KiB
#include "boxes.h" #include <cassert> #include <iostream> #include <vector> #include <algorithm> #define ll long long #define ff first #define ss second #define ln "\n" using namespace std; vector<ll> pos; ll n, k, l; long long delivery(int N, int K, int L, int p[]) { n=N; k=K; l=L; pos.resize(n); for (ll i=0; i<n; i++){ pos[i] = p[i]; } vector<ll> cl(n), acl(n); for (ll i=0; i<n; i++){ cl[i] = pos[i]*2; if (i>=k) cl[i]+=cl[i-k]; } for (ll i=n-1; i>=0; i--){ acl[i]=(l-pos[i])*2; if (i+k<n) acl[i]+=acl[i+k]; } ll ans=acl[0]; for (ll i=0; i<n; i++){ ll res = cl[i]; if (i+1<n) res+=acl[i+1]; ans=min(ans, res); } for (ll i=k; i<=n; i++){ ll res=l; if (i-k-1>=0) res+=cl[i-k-1]; if (i<n) res+=acl[i]; ans=min(ans, res); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...