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;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll delivery(int n, int k, int l, int p[]) {
ll i=0;
ll ans = 0;
while(i < n) {
ll bg = p[i], ed;
RE(j,k) {
if(i == n)
break;
ed = p[i++];
}
ll add = l;
add = min(add, ed*2ll);
add = min(add, l*2ll - bg*2ll);
ans += add;
}
i = n-1;
ll ans2 = 0;
while(i >= 0) {
ll bg, ed = p[i];
RE(j,k) {
if(i == -1)
break;
bg = p[i--];
}
ll add = l;
add = min(add, ed*2ll);
add = min(add, l*2ll - bg*2ll);
ans2 += add;
}
return min(ans, ans2);
}
Compilation message (stderr)
boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:60:30: warning: 'bg' may be used uninitialized in this function [-Wmaybe-uninitialized]
60 | add = min(add, l*2ll - bg*2ll);
| ~~~~~~^~~~~~~~
boxes.cpp:44:26: warning: 'ed' may be used uninitialized in this function [-Wmaybe-uninitialized]
44 | add = min(add, ed*2ll);
| ~~^~~~
# | 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... |