Submission #82036

#TimeUsernameProblemLanguageResultExecution timeMemory
82036farukkastamonudaBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
568 ms171104 KiB
#include "boxes.h" #include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000000000000000 #define md 1000000007 #define li 10000005 #define mp make_pair #define pb push_back using namespace std; vector<lo int> l, r; lo int ans = inf; long long delivery(int N, int K, int L, int positions[]){ for(int i = 0;i < N; i ++){ if(positions[i] <= L / 2){ l.pb(positions[i] * 2); } else{ r.pb( 2 * L - positions[i] * 2); } } reverse(r.begin(),r.end()); for(int i = K;i < (int)l.size(); i ++){ l[i]+=l[i-K]; } for(int i = K;i < (int)r.size(); i ++){ r[i] += r[i - K]; } for(int i = 0;i <= K; i ++){ int x = i; int y = K - i; ans = min(ans, (x<(int)l.size()?l[l.size()-1-x]:0)+(y<(int)r.size()?r[r.size()-1-y]:0)+L); } ans=min(ans,((int)l.size()>0?l.back():0)+((int)r.size()>0?r.back():0)); 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...