#include "boxes.h"
#include<bits/stdc++.h>
#define pl pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b, c) for (ll i=a; i<=b; i+=c)
#define FORE(i, a, b, c) for (ll i=a; i>=b; i+=c)
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll Mod = 998244353;
const int maxn = 1e7+1;
const ll Inf = 1e10;
inline int dis(int a, int l)
{
return min(a, l-a);
}
ll delivery(int n, int k, int l, int A[])
{
ll a = -1, b = n, ans = 0;
if (n % k != 0) {
ans += min(dis(A[a+n%k],l), dis(A[b-n%k],l)) + dis(min(dis(A[a+n%k],l), dis(A[b-n%k],l)),l);
if (dis(A[a+n%k],l) <= dis(A[b-n%k],l)) a += n%k;
else b -= n%k;
}
while (a + 1 != b) {
if (b - a == k + 1) {
if (A[b-1] <= l/2) ans += (l/2)*2;
else ans += l;
break;
}
else {
ans += min(dis(A[a+k],l), dis(A[b-k],l)) + dis(min(dis(A[a+k],l), dis(A[b-k],l)),l);
if (dis(A[a+k],l) <= dis(A[b-k],l)) a+=k;
else b-=k;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |