Submission #129863

# Submission time Handle Problem Language Result Execution time Memory
129863 2019-07-13T11:32:21 Z MoNsTeR_CuBe Boxes with souvenirs (IOI15_boxes) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "boxes.h"
using namespace std;

long long delivery(int N, int K, int L, int p[]) {
	#define int long long

	vector< int > left;

	for(int i = 0; i < N; i++){
		left.push_back(min(L,2*(p[i])));
		if(left.size() >= K){
            left.back()+=left[i-K];
		}
	}
	//left.push_back(L-last);
	/*cout << "LEFT "<< endl;
	for(int a : left) cout << a << ' ';
	cout << endl;*/

	vector< int > right;

	curr = K;
	last = L;
	currCost = 0;

	for(int i = N-1; i >= 0; i--){
		right.push_back(min(L, 2*(L-p[i])));
		if(right.size() >= K){
            right.back() += right[i-K];
		}
	}
	//right.push_back(last + currCost);
	/*cout << "RIGHT " << endl;
	for(int a : right) cout << a << ' ';
	cout << endl;*/

	//reverse(right.begin(), right.end());
	int ans = min(right[N - 1], left[N-1]);

	for(int i = 0; i < N; i++){
		if(N - 2 - i < 0) continue;
		//cout << "INDEX " << i << ' ' << left[i] << ' ' << right[N-2-i] << ' ' << min(p[i], L-p[i]) << ' ' << min(p[i+1], L-p[i+1]) << endl;
		//cout << p[N-2-i] << ' ' << L-p[N-2-i] << endl;
		ans = min(ans, left[i] + right[N - 2 - i]);
	}

	return ans;
	#undef int
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(left.size() >= K){
      ~~~~~~~~~~~~^~~~
boxes.cpp:23:2: error: 'curr' was not declared in this scope
  curr = K;
  ^~~~
boxes.cpp:23:2: note: suggested alternative: 'cbrt'
  curr = K;
  ^~~~
  cbrt
boxes.cpp:24:2: error: 'last' was not declared in this scope
  last = L;
  ^~~~
boxes.cpp:24:2: note: suggested alternative: 'left'
  last = L;
  ^~~~
  left
boxes.cpp:25:2: error: 'currCost' was not declared in this scope
  currCost = 0;
  ^~~~~~~~
boxes.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(right.size() >= K){
      ~~~~~~~~~~~~~^~~~