이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <climits>
#include <cstring>
#include <functional>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using ii = pair<int,int>;
using vii = vector<pair<int,int>>;
using vb = vector<bool>;
template<typename T>
using Graph = vector<vector<T>>;
ll delivery(int n, int K, int L, int p[])
{
int k = K;
ll ans = 0, lst = 0;
for(int j = 0; j < n; ++j)
{
if(k == 0)
{
ans += 1LL * (L - p[j]);
k = K;
lst = 0;
}
ans += 1LL * (L - p[j] + lst);
--k;
lst = p[j];
}
if(lst != 0) ans += 1LL * min(lst, L - lst);
// TODO handle case where i go to p[0] from other side
for(int i = 0; i < n; ++i)
{
k = K;
lst = 0;
ll r = 0;
// dont go beyond i
for(int j = 0; j <= i; ++j)
{
if(k == 0)
{
r += p[j];
lst = 0;
k = K;
}
r += 1LL * p[j] - lst;
lst = p[j];
--k;
}
if(lst != 0)
r += 1LL * min(lst, L - lst);
k = K;
lst = 0;
for(int j = i + 1; j < n; ++j)
{
if(k == 0)
{
r += L - p[j];
lst = 0;
k = K;
}
r += 1LL * (L - p[j] + lst);
--k;
lst = p[j];
}
if(lst != 0)
r += 1LL * min(lst, L - lst);
ans = min(ans, r);
}
return ans;
}
# | 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... |