# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
420138 | ismoilov | Boxes with souvenirs (IOI15_boxes) | C++14 | 1 ms | 300 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 "boxes.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
ll delivery(int n, int k, int L, int p[]) {
vector <ll> a, b;
ll ans = 0, l = L;
fp(i,0,n){
if(p[i] <= l-p[i])
a.push_back(p[i]*2);
else
b.push_back((l-p[i])*2);
}
sort(all(a));
sort(all(b));
ll x = k-1;
while(x < a.size())
ans += a[x], x += k;
x = k-1;
while(x < b.size())
ans += b[x], x += k;
ll aa = 0, bb = 0;
if(a.size() % k != 0)
aa = a[a.size()-1];
if(b.size() % k != 0)
bb = b[b.size()-1];
ans += min(l, aa+bb);
ll ans1 = 0;
x = a.size()-1;
while(x >= 0)
ans1 += a[x], x -= k;
x = b.size()-1;
while(x >= 0)
ans1 += b[x], x -= k;
if(a.size() % k > 0)
ans1 += a[a.size()%k-1];
if(b.size() % k > 0)
ans1 += b[a.size()%k-1];
return min(ans1, 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... |