이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"boxes.h"
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
vector<vector<ll> > rua,rub;
ll delivery(int N,int K,int L,int P[]){
rep(i,K){
vector<ll> vec;
rua.push_back(vec);
rub.push_back(vec);
rua[i].push_back(0);
rub[i].push_back(0);
}
rep(i,N){
rua[i%K].push_back(rua[i%K].back()+(ll)(P[i]*2));
rub[i%K].push_back(rub[i%K].back()+(ll)((L-P[i])*2));
}
ll ans=1e17;
for(int i=0;i+K-1<N;i++){
ll res=L,rec=0;
//for(int j=i-1;j>=0;j-=K)res+=P[j]*2;
int a=i-1;
if(a>=0){
ll val=rua[a%K][a/K+1];
res+=val,rec+=val;
}
//for(int j=i+K;j<N;j+=K)res+=(L-P[j])*2;
int b=i+K;
if(b<N){
res+=rub[b%K].back()-rub[b%K][b/K];
}
chmin(ans,res);
b=i;
if(b<N){
rec+=rub[b%K].back()-rub[b%K][b/K];
}
chmin(ans,rec);
}
for(int i=N-K+1;i<=N;i++){
ll res=0;
//for(int j=i-1;j>=0;j-=K)res+=P[j]*2;
int a=i-1;
if(a>=0){
res+=rua[a%K][a/K+1];
}
//for(int j=i;j<N;j+=K)res+=(L-P[j])*2;
int b=i;
if(b<N){
res+=rub[b%K].back()-rub[b%K][b/K];
}
chmin(ans,res);
}
return ans;
}
/*
int main(){
int n,k,l,p[110];
cin>>n>>k>>l;
rep(i,n){
cin>>p[i];
}
cout<<delivery(n,k,l,p)<<endl;
}*/
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp:12:0: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
#pragma gcc optimize("O3")
boxes.cpp:13:0: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
#pragma gcc optimize("unroll-loops")
boxes.cpp:14:0: warning: ignoring #pragma gcc target [-Wunknown-pragmas]
#pragma gcc target("avx2,see4")
# | 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... |