# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
778078 | Jarif_Rahman | Boxes with souvenirs (IOI15_boxes) | C++17 | 2060 ms | 278436 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 pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
const int K = 1e7;
ll S[K];
vector<ll> sth[K];
ll delivery(int n, int k, int L, int P[]){
vector<ll> A(n+1), B(n+1);
A[0] = 0, B[n] = 0;
fill(S, S+k, 0);
for(int i = 1; i <= n; i++){
S[i%k]+=2*P[i-1];
A[i] = S[i%k];
}
fill(S, S+k, 0);
for(int i = n-1; i >= 0; i--){
S[(n-i)%k]+=2*(L-P[i]);
B[i] = S[(n-i)%k];
}
vector<ll> C(n+1);
C[n] = 0;
for(int i = n-1; i >= 0; i--){
C[i] = ll((n-i+k-1)/k)*L;
sth[i%k].pb(B[i]);
for(int j = 0; j < sth[i%k].size(); j++)
C[i] = min(C[i], *(sth[i%k].rbegin()+j)+ll(L)*j);
}
ll ans = 1e18;
for(int i = 0; i <= n; i++) ans = min(ans, A[i]+C[i]);
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... |