#include "boxes.h"
#include <vector>
#include <math.h>
using namespace std;
#define ll long long
/*
Lemma:
this is dp and I will move on to q2 after getting the first subtask
New Lemma:
the second subtask does not use dp.
hence I will only move on to q2 after solving the first two subtasks
*/
long long delivery(int N, int K, int L, int p[]) {
vector<int> ns;
ns = {0};
for(int i=0; i<N; i++){
ns.push_back(p[i]);
}
ll ans=0;
int biggest_gap=L-ns[N-1];
for(int i=1; i<N+1; i++){
biggest_gap = max(biggest_gap, ns[i]-ns[i-1]);
}
/*
ll cur, furthest=0;
for(auto e:ns){
cur = min(e, L-e);
ans += 2*cur;
furthest = max(cur, furthest);
}
*/
return min(L, (L-biggest_gap)*2);
}
# | 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... |