Submission #320367

#TimeUsernameProblemLanguageResultExecution timeMemory
320367nikatamlianiBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; int delivery(int N, int K, int L, int positions[]) { long long p[N], s[N]; for(int i = 0; i < N; ++i) { p[i] = 2 * positions[i]; if(i >= K) { p[i] += p[i - K]; } } for(int i = N - 1; i >= 0; --i) { s[i] = 2 * (L - positions[i]); if(i + K < N) { s[i] += s[i + K]; } } long long answer = p[N - 1]; for(int i = 0; i < N - 1; ++i) { answer = min(answer, p[i] + s[i + 1]); } for(int start = 0; start + K - 1 < N; ++start) { int end = start + K - 1; long long left = (start > 0 ? p[start - 1] : 0); long long right = (end < N - 1 ? s[end + 1] : 0); long long middle = L; answer = min(answer, left + middle + right); } return answer; } // int main() { // int pos[] = {1, 2, 5}; // cout << delivery(3, 2, 8, pos) << '\n'; // }

Compilation message (stderr)

boxes.cpp:4:5: error: ambiguating new declaration of 'int delivery(int, int, int, int*)'
    4 | int delivery(int N, int K, int L, int positions[]) {
      |     ^~~~~~~~
In file included from boxes.cpp:2:
boxes.h:4:11: note: old declaration 'long long int delivery(int, int, int, int*)'
    4 | long long delivery(int N, int K, int L, int p[]);
      |           ^~~~~~~~
boxes.cpp: In function 'int delivery(int, int, int, int*)':
boxes.cpp:29:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   29 |     return answer;
      |            ^~~~~~