이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define si second
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;
template<typename T> bool chmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
int n,k,l,a[10000010];
vector<pi> pos;
ll pref,suff,cnt,ans;
long long delivery(int N, int K, int L, int p[]) {
n=N,k=K,l=L;
for (int i = 0; i < n; ++i) a[i+1]=p[i];
int lx=0,rx=n+1;
while (lx<rx-1) {
if (a[lx+1]<l-a[rx-1]+1) {
pos.push_back({a[++lx],0});
} else {
pos.push_back({a[--rx],1});
}
}
reverse(pos.begin(),pos.end());
suff=l+1;
for (auto i: pos) {
if (i.si==0) {
pref=i.fi;
} else {
suff=i.fi;
}
++cnt;
if (cnt==k) {
if (pref+l-suff+1<=l/2) ans += 2*(pref+l-suff+1);
else ans += l;
cnt=0; pref=0; suff=l+1;
}
}
if (cnt) {
if (pref+l-suff+1<=l/2) ans += 2*(pref+l-suff+1);
else ans += l;
}
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... |