Submission #57891

# Submission time Handle Problem Language Result Execution time Memory
57891 2018-07-16T13:38:34 Z E869120 Boxes with souvenirs (IOI15_boxes) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long delivery(long long N, long long K, long long L, long long pos[]) {
	long long minx = (1LL << 60);

	for (int i = 0; i <= K; i++) {
		vector<pair<int, int>>vec;
		int cx = i;
		while (cx < i + N) {
			vec.push_back(make_pair(cx, min(i + N - 1, cx + K - 1)));
			cx += K;
		}
		long long sum = 0;
		for (int j = 0; j < vec.size(); j++) {
			long long V1 = pos[vec[j].first % N], V2 = pos[vec[j].second % N];
			long long ret = min(V2, L - V1);

			if (vec[j].first < N && vec[j].second >= N) {
				sum += max(V1, L - V1) + max(V2, L - V2);
			}
			else {
				sum += ret;
			}
		}
		minx = min(minx, sum);
	}

	return minx * 2;
}

Compilation message

boxes.cpp: In function 'long long int delivery(long long int, long long int, long long int, long long int*)':
boxes.cpp:14:7: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
    cx += K;
    ~~~^~~~
boxes.cpp:17:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < vec.size(); j++) {
                   ~~^~~~~~~~~~~~
/tmp/ccbTQwVr.o: In function `main':
grader.c:(.text.startup+0x22f): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status