이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<boxes.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
//#define int ll
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <pi, int>
#define vi vector <int>
const ll nmax=1e5+2;
const ll mod = 998244353;
ll delivery(int n, int k, int l, int pos[]){
ll ans=1000000000000000000;
int pcarne[n];
ll dp1[n], dp2[n];
for(int i=0; i<n; i++) pcarne[i]=pos[n-i-1];
for(int i=0; i<n; i++){
if(i<k) dp1[i]=1LL*pos[i]*2;
else dp1[i]=dp1[i-k]+1LL*pos[i]*2;
}
for(int i=0; i<n; i++){
if(i<k) dp2[i]=(l-pos[n-i-1])*2;
else dp2[i]=dp2[i-k]+1LL*(l-pos[n-i-1])*2;
}
//for(int i=0; i<n; i++) cout<<dp1[i]<<" "; cout<<endl;for(int i=0; i<n; i++) cout<<dp2[i]<<" "; cout<<endl;
for(int i=0; i<n-1; i++){
ans=min(ans, dp1[i]+dp2[n-2-i]);
}
ans=min(ans, min(dp1[n-1], dp2[n-1]));
//cout<<"ans: "<<ans<<endl;
if(n<=k) ans=min(ans, 1LL*l);
else{
for(int i=0; i<=n-k-2; i++){
ans=min(ans, dp1[i]+l+dp2[n-2-k-i]);
}
ans=min(ans, 1LL*l+min(dp1[n-k-1], dp2[n-k-1]));
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:20:9: warning: variable 'pcarne' set but not used [-Wunused-but-set-variable]
int pcarne[n];
^~~~~~
# | 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... |