이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*#pragma GCC optimize("O3")*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#define ordered_set tree<int, null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000001
#define PI 3.14159265358979323846
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
long long pr1[N+2], pr2[N+2], ans=0;
pr1[0]=0;
pr2[N+1]=0;
for(int i = 1; i <= N; i++)
pr1[i]=pr1[i-1]+p[i-1];
for(int i=N; i >= 1; i--)
pr2[i]=pr2[i+1]+L-p[i-1];
int l=1, r=N;
while(l <= r)
{
long long x=pr1[min(r, l+K-1)]-pr1[l-1], y=pr2[max(l, r-K+1)]-pr2[r+1], d=L;
if(x <= y)
l=min(r, l+K-1)+1;
else
r=max(l, r-K+1)-1;
ans+=min(min(2*x, 2*y), d);
}
return ans;
}
//size
# | 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... |