이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
#define debug(args...) fprintf(stderr, args)
typedef long long int lli;
using namespace std;
const lli maxn = 2e7, INF = 1e18;
lli n, k, m, dp1[maxn], dp2[maxn], ini[maxn], fim[maxn], resp;
long long delivery(int N, int K, int L, int p[])
{
	n = N; m = L; k = K; resp = INF;
	
	for(int x = 0; x < n; x++)
		ini[x] = 2*p[x] + ((x >= k)?ini[x-k]:0);
	for(int x = n-1; x >= 0; x--)
		fim[x] = 2*(m-p[x]) + ((x+k < n)?ini[x+k]:0);
	
	resp = min(ini[n-1], fim[0]);
	for(int x = 0; x < n-1; x++)
		resp = min(resp, ini[x]+fim[x+1]);
	if(k >= m)	resp = min(resp, m);
	else
	{
	for(int x = 1; x+k < n; x++)
		resp = min(resp, ini[x-1]+m+fim[x+k]);		
		resp = min(resp, m+ini[n-k-1]);
		resp = min(resp, m+fim[k]);
	}
	
//	ll ans = min(2*suf[0], 2*pref[N-1]);
//	if(K >= N) ans = min(ans, (ll) L);
//	for(int i = 0; i < N-1; i++) ans = min(ans, 2*suf[i+1] + 2*pref[i]);
//	// achar  volta
//	if(K < N){
//		for(int i = 1; i+K < N; i++ ){
//			ans = min(ans, L + 2*pref[i-1] + 2*suf[i+K]);
//		}
//		ans = min(ans, L + 2*pref[N-K-1]);
//		ans = min(ans, L + 2*suf[K]); // dou a volta, e pego o resto com uma ida do outro lado
//	}
	
//	debug("%d\n",resp);
//	for(int x = 0; x < n; x++)
//		debug("ini[%d] = %d, fim[%d] = %d// %d // %d\n",x,ini[x],x,fim[x],ini[x]+fim[x+1],ini[x-1]+m+fim[x+k]);
	return resp;
}
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:15:15: warning: conversion from 'lli' {aka 'long long int'} to 'int' may change value [-Wconversion]
   15 |  for(int x = n-1; x >= 0; x--)
      |              ~^~
boxes.cpp:24:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   24 |  for(int x = 1; x+k < n; x++)
      |  ^~~
boxes.cpp:26:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   26 |   resp = min(resp, m+ini[n-k-1]);
      |   ^~~~| # | 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... |