이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define orta ((l+r)>>1)
#define INF 1000000009
#define mod 1000000007
#define ppair(x); cerr << "(" << x.first << ", " << x.second << ")\n";
#define bas(x) #x << ": " << x << " "
#define prarr(x, n); cerr << #x << ": "; for(int qsd = 0; qsd < n; qsd++) cerr << x[qsd] << " "; cerr << "\n";
#define prarrv(x); cerr << #x << ": "; for(int qsd = 0; qsd < (int)x.size(); qsd++) cerr << x[qsd] << " "; cerr << "\n";
using namespace std;
typedef long long ll;
int n, k, s;
vector<int> arr;
ll delivery(int N, int K, int L, int p[]) {
n = N;
k = K;
s = L;
for (int i = 0; i < n; i++) arr.pb(p[i]);
sort(arr.begin(), arr.end());
ll ans = 0;
int artik = n%k;
int l = 0;
int r = n-1;
ll bas, son;
if (artik){
bas = arr[l+artik-1];
son = s - arr[r-artik+1];
if (bas < son){
ans = bas*2;
l += artik;
} else {
ans = son*2;
r -= artik;
}
}
while (l <= r){
bas = arr[l+k-1];
son = s-arr[r-k+1];
//cout << bas(bas) << bas(son) << endl;
if (2*bas > s && 2*son > s){
ans += s;
l += k;
continue;
}
if (bas < son) ans += bas*2, l += k;
else ans += son*2, r -= k;
}
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... |