제출 #287877

#제출 시각아이디문제언어결과실행 시간메모리
287877Bill_00Boxes with souvenirs (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
long long pre[10000001],suf[10000001];
long long delivery(int n, int k, int l, int o[]){
	for(int i=0;i<n;i++){
		p[i+1]=o[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=k;i++){
		pre[i]=2*p[i];
	}
	pre[0]=0,suf[n+1]=0;
	for(int i=k+1;i<=n;i++){
		pre[i]=pre[i-k]+2*p[i];
	}
	for(int i=1;i<=k;i++){
		suf[n+1-i]=2*(l-p[n+1-i]);
	}
	for(int i=k+1;i<=n;i++){
		suf[n+1-i]=suf[n+1-i+k]+2*(l-p[n+1-i]);
	}
	long long ans=1e18;
	for(int i=0;i<=n;i++){
		ans=min(ans,pre[i]+suf[i+1]);
	}
	for(int i=0;i<=n-k;i++){
		ans=min(ans,pre[i]+suf[i+k+1]+l);
	}
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:7:3: error: 'p' was not declared in this scope
    7 |   p[i+1]=o[i];
      |   ^
boxes.cpp:9:7: error: 'a' was not declared in this scope
    9 |  sort(a+1,a+n+1);
      |       ^
boxes.cpp:11:12: error: 'p' was not declared in this scope
   11 |   pre[i]=2*p[i];
      |            ^
boxes.cpp:15:21: error: 'p' was not declared in this scope
   15 |   pre[i]=pre[i-k]+2*p[i];
      |                     ^
boxes.cpp:18:19: error: 'p' was not declared in this scope
   18 |   suf[n+1-i]=2*(l-p[n+1-i]);
      |                   ^
boxes.cpp:21:32: error: 'p' was not declared in this scope
   21 |   suf[n+1-i]=suf[n+1-i+k]+2*(l-p[n+1-i]);
      |                                ^