이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const int MAXN = 0;
ll delivery (int n, int k, int l, int p[]){
vector<ll> respl(n), respr(n);
for(int i = 0; i < n; i++){
respl[i] = p[i]*2;
if(i-k >= 0){
respl[i]+=respl[i-k];
}
}
//cerr << 'a' << endl;
for(int i = n-1; i >= 0; i--){
respr[i] = (l-p[i])*2;
if(i+k < n){
respr[i]+= respr[i+k];
}
}
//cerr << 'a' << endl;
ll resp = INFL;
for(int i = 0; i <= n; i++){ // testando para não ter ciclo
resp = min(resp, (i > 0? respl[i-1] : 0) + (i< n ? respr[i] : 0));
}
//cerr << 'a' << endl;
for(int i = 0; i < n; i++){ // intervalo vai de i até i+k-1
if(i+k > n)
break;
resp = min(resp, (i > 0? respl[i-1] : 0) + (i+k < n? respr[i+k] : 0) + l);
}
return resp;
}
# | 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... |