# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897631 | oblantis | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 512 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>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
const ll inf = 1e18 + 10000;
const int mod = 1e9+7;
const int maxn = 1e5 + 12;
long long delivery(int n, int k, int l, int p[]) {
deque<int> ls, mr;
for(int i = 0; i < n; i++){
if(p[i] <= l / 2)ls.pb(p[i]);
else mr.pb(p[i]);
}
ll ret = 0;
while(ls.size() >= k){
int x = ls.back();
for(int i = 0; i < k; i++){
ls.pop_back();
}
ret += x * 2;
}
while(mr.size() >= k){
int x = mr.front();
for(int i = 0; i < k; i++){
mr.pop_front();
}
ret += (l - x) * 2;
}
if(mr.empty() && ls.empty())return ret;
else if(mr.empty() && !ls.empty())ret += ls.back() * 2;
else if(!mr.empty() && ls.empty())ret += (l - mr.front()) * 2;
else if(mr.size() + ls.size() > k)ret += ls.back() * 2 + (l - mr.front()) * 2;
else ret += min(l, ls.back() * 2 + (l - mr.front()) * 2);
return ret;
}
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... |