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>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
int const N=1e7+3;
ll delivery(int n, int K, int L, int p1[]) {
vi p(n);
F0R(i,n)p[i]=p1[i];
if(K==1)
{
ll ans=0;
F0R(i,n)
{
ans+=min(p[i],L-p[i]);
}
return ans*2;
}
else if(K==n)
{
p.pb(0);
p.pb(L);
sort(all(p));
ll ans=4e18;
F0R(i,n+2)
{
ll cand = p[i] + L-p[i+1];
ans=min(ans,cand);
}
return ans*2;
}
}
Compilation message (stderr)
boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:27:8: warning: control reaches end of non-void function [-Wreturn-type]
27 | vi p(n);
| ^
# | 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... |