# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
783283 | Matblube | Boxes with souvenirs (IOI15_boxes) | C++14 | 0 ms | 340 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 <iostream>
#include <iomanip>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
#define dbg(x) cerr<<#x<<": "<<x<<"\n";
#define fr(i, x) for(ll i=0 ; i<x ; i++)
#define fra(x, v) for(auto x:v)
#define fra1(x,v) for(auto &x:v)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define pb(x) push_back(x)
#define F first
#define S second
const ll maxN=1e6;
ll dp[maxN], dp1[maxN];
long long delivery(int N, int K, int L, int p[]) {
ll n=N, k=K, l=L;
vector<ll>v(n+1);
fr(i, n) v[i+1]=p[i];
dp[1]=dp1[n]=0;
for(ll i=1; i <=n ; i++) dp[i]+=(min(l, 2*v[i]))+dp[i-1];
for(ll i=n-1 ; i>0 ; i--) dp1[i]+=(min(l, 2*(l-v[i])))+dp1[i+1];
ll ans=1e18;
for(ll i=1 ; i<=n ; i++){
if(i==n){
ans=min(ans, dp[i]+dp1[1]);
continue;
}
ans=min(ans, dp[i]+dp1[i+1]);
}
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... |