# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120789 | SalihSahin | Boxes with souvenirs (IOI15_boxes) | C++14 | 1 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#include "boxes.h"
const long long inf = 1e17;
long long delivery(int N, int K, int L, int p[]) {
vector<int> pos;
for(int i = 0; i < N; i++){
if(p[i] > 0) pos.pb(p[i]);
}
N = pos.size();
vector<pair<int, long long> > lop, rop; // kac kisiyi, ne kadar surede
lop.pb({0, 0LL}), rop.pb({0, 0LL});
int ind = N-1;
for(int i = 1; i <= N/K; i++){
int wh = K;
while(wh >= 1 && ind >= 1 && pos[ind-1] >= (N + 1)/2){
wh--;
ind--;
}
int new_taken = ((N-1) - ind) - rop.back().first;
long long op = ((N-1) - pos[ind] + 1) * 2 + rop.back().second;
rop.pb({new_taken, op});
}
ind = 0;
for(int i = 1; i <= N/K; i++){
int wh = K;
while(wh >= 1 && ind < N-1 && pos[ind+1] <= (N-1)/2){
wh--;
ind++;
}
int new_taken = ind - rop.back().first;
long long op = pos[ind] * 2 + rop.back().second;
lop.pb({new_taken, op});
}
long long ans = inf;
for(int l = 0; l < lop.size(); l++){
for(int r = 0; r < rop.size(); r++){
int rem = N - lop[l].first - rop[r].first;
long long calc = lop[l].second + rop[r].second + ((rem + K - 1)/K) * L;
ans = min(ans, calc);
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |