# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127282 | ekrem | Boxes with souvenirs (IOI15_boxes) | C++98 | 8 ms | 380 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>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
typedef long long ll;
typedef pair < int , int > ii;
ll k, l, cvp, ans, bas[N], son[N];
ll ansver(int i, int j){
return ((i>=0)?bas[i]:0ll) + son[j] + 1ll*(j - i - 1 + k - 1)/k*l;
}
ll delivery(int n, int kk, int ll, int p[]) {k = kk;l = ll;
for(int i = 0; i < n; i++)
bas[i] = (i - k >= 0) ? bas[i - k] + p[i]*2ll : p[i]*2ll;
for(int i = n - 1; i >= 0; i--)
son[i] = (n > k + i) ? son[i + k] + (l - p[i])*2ll : (l - p[i])*2ll;
cvp = ans = son[0];
int opt = 0;
for(int i = -1; i < n; i++){
// int bas = i + 1, son = n;
// while(bas < son){
// if(ansver(i, orta) >= ansver(i, orta + 1))
// bas = orta + 1;
// else
// son = orta;
// }
for(int j = max(i + 1, opt); j <= n; j++){
// cout << i << " " << j << " = " << ansver(i, j) << endl;
if(ansver(i, j) <= cvp){
cvp = ansver(i, j);
opt = j;
}
}
// cout << i << " " << opt << " " << cvp << endl;
ans = min(ans, cvp);
}
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... |