Submission #717325

#TimeUsernameProblemLanguageResultExecution timeMemory
717325tigarBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 ms212 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int dpcw[10000010], dpccw[10000010], pos[10000010]; ll delivery(int N, int K, int L, int* positions) { sort(positions, positions+N); for(int i=0; i<K; i++)dpccw[i]=min(L, 2*positions[i]); for(int i=K; i<N; i++)dpccw[i]=dpccw[i-K]+min(L, 2*positions[i]); for(int i=N-1; i>=N-K; i--)dpcw[i]=min(L, (L-positions[i])*2); for(int i=N-K-1; i>=0; i--)dpcw[i]=dpcw[i+K]+min(L, (L-positions[i])*2); int rezz=dpcw[0]; /*for(int i=0; i<N; i++)cout<<dpcw[i]<<" "; cout<<"\n"; for(int i=0; i<N; i++)cout<<dpccw[i]<<" ";*/ for(int i=0; i<N-1; i++)rezz=min(rezz, dpccw[i]+dpcw[i+1]); rezz=min(rezz, dpccw[N-1]); return rezz; } /*int main() { int n, k, l; cin>>n>>k>>l; for(int i=0; i<n; i++)cin>>pos[i]; cout<<delivery(n, k, l, pos); return 0; } /*3 2 8 1 2 5*/

Compilation message (stderr)

boxes.cpp:33:1: warning: "/*" within comment [-Wcomment]
   33 | /*3 2 8
      |
#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...