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 fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define debug(x) cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<ll, ll>
#define ld long double
#define nl endl
#define tb '\t'
#define sp ' '
#define sqr(x) (x)*(x)
#define arr3 array<ll, 3>
using namespace std;
const ll MX=200005, MOD=1000000007, BLOCK=160, INF=1e9+7, LG=62;
const ll INFF=1000000000000000004;
const ld ERR=1e-6, pi=3.14159265358979323846;
long long delivery(int N, int K, int L, int p[]) {
int M=L/2, st=0;
while(st<N && !p[st])
st++;
ll ans1=0, ans2=0;
for(int i=st; i<N; i+=K){
int le=p[i], ri=p[min(N, i+K)-1];
if(le<=M && ri>M){
ans1+=N;
}else if(ri<=M){
ans1+=2*ri;
}else{
ans1+=2*(L-le);
}
le=p[max(st, N-i+st-K+1)], ri=p[N-i+st];
if(le<=M && ri>M){
ans2+=N;
}else if(ri<=M){
ans2+=2*ri;
}else{
ans2+=2*(L-le);
}
}
return min(ans1, ans2);
}
// int main() {
// int N, K, L, i;
// cin >> N >> K >> L;
// int *p = (int*)malloc(sizeof(int) * (unsigned int)N);
// for (i = 0; i < N; i++) {
// cin >> p[i];
// }
// cout << delivery(N, K, L, p) << nl;
// return 0;
// }
# | 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... |