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<bits/stdc++.h>
using namespace std;
const int INF = 5e18 + 15;;
typedef long long ll;
ll getDist(ll x, ll y, ll l){
if(y > x) swap(x, y);
return min(x - y, l - x + y);
}
ll delivery(int n, int k, int l, int p[]){
if(k == 1){
ll ans = 0;
for(int i = 0; i < n; i++)
ans += 2 * getDist(0, p[i], l);
return ans;
}
ll mx = p[n - 1], mn = p[0], ans = INF;
ans = min(ans, getDist(0, mx, l) + getDist(mx, mn, l) + getDist(mn, 0, l));
ans = min(ans, getDist(0, mn, l) + getDist(mn, mx, l) + getDist(mx, 0, l));
return ans;
}
Compilation message (stderr)
boxes.cpp:4:22: warning: overflow in conversion from 'double' to 'int' changes value from '5.0e+18' to '2147483647' [-Woverflow]
4 | const int INF = 5e18 + 15;;
| ~~~~~^~~~
# | 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... |