이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define pb push_back
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ii = pair<int,int>;
using iii = tuple<int,int,int>;
const int inf = 2e9+1;
const int mod = 1e9+7;
const int maxn = 1e7+10;
template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }
ll R[maxn], L[maxn];
ll delivery(int n, int k, int l, int p[]){
ll cur = 0;
int y = 0;
for(int i=0;i<n;++i)if(p[i]!=0)++y;
for(int i=0;i<y;++i)p[i] = p[n-y+i];
n = y;
for(int i=n-1;~i;--i){
if(i>=n-k)R[i] = min(ll(l), ll(2*(l-p[i])));
else R[i] = min(ll(l), ll(2*(l-p[i]))) + R[i+k];
}
for(int i=0;i<n;++i){
if(i<k)L[i] = min(ll(l), ll(2*p[i]));
else L[i] = min(ll(l), ll(2*p[i])) + L[i-k];
}
ll resp = min(R[0], L[n-1]);
for(int i=1;i<n;++i)ckmin(resp, R[i] + L[i-1]);
return resp;
}
// int positions[maxn];
// int main(){
// int n,k,l;cin>>n>>k>>l;
// for(int i=0;i<n;++i)cin>>positions[i];
// cout<<delivery(n,k,l,positions)<<endl;
// }
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:25:8: warning: unused variable 'cur' [-Wunused-variable]
25 | ll cur = 0;
| ^~~
# | 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... |