이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <iostream>
using namespace std;
long long delivery( int N, int K, int L, int positions[] )
{
long long answer = 0;
int cnt = N, jnt = 0;
while( cnt ){
int l = 0, r = 0;
if( cnt >= K ){
l = positions[ jnt ];
r = positions[ jnt + K - 1 ];
jnt += K;
cnt -= K;
}
else{
l = positions[ jnt ];
r = positions[ jnt + cnt - 1 ];
jnt += cnt;
cnt = 0;
}
int mnl = min( l, (r - l) + (L - r) );
int mnr = min( (L - r), (r - l) + l );
answer += min( (L - r) + (r - l) + mnl, l + (r - l) + mnr );
}
return answer;
}
/*
int main()
{
int N, K, L, positions[1000];
cin >> N >> K >> L;
for ( int i = 0; i < N; i ++ ){
cin >> positions[i];
}
cout << delivery( N, K, L, positions );
return 0;
}
/*
3 2 8
1 2 5
*/
/**/
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp:45:1: warning: "/*" within comment [-Wcomment]
/*
# | 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... |