Submission #346826

#TimeUsernameProblemLanguageResultExecution timeMemory
3468261binBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; ll N, K, L, x, ans; vector<ll> arr, A, B; ll delivery(ll N, ll K, ll L, ll p[]) { arr.resize(N + 2); for (int i = 1; i <= N; i++) arr[i] = p[i - 1]; A.resize(N + 2); B.resize(N + 2); for (int i = 0; i <= N; i++) { if (i <= K) A[i] = arr[i] * 2; else A[i] = arr[i] * 2 + A[i - K]; } for (int i = N + 1; i; i--) { if (i >= N + 1 - K) B[i] = (L - arr[i]) * 2; else B[i] = (L - arr[i]) * 2 + B[i + K]; } ans = 198765432198765432; for (int i = 0; i <= N; i++) ans = min(ans, A[i] + B[i + 1]); return ans; }

Compilation message (stderr)

boxes.cpp: In function 'll delivery(ll, ll, ll, ll*)':
boxes.cpp:11:37: warning: declaration of 'L' shadows a global declaration [-Wshadow]
   11 | ll delivery(ll N, ll K, ll L, ll p[]) {
      |                                     ^
boxes.cpp:8:10: note: shadowed declaration is here
    8 | ll N, K, L, x, ans;
      |          ^
boxes.cpp:11:37: warning: declaration of 'K' shadows a global declaration [-Wshadow]
   11 | ll delivery(ll N, ll K, ll L, ll p[]) {
      |                                     ^
boxes.cpp:8:7: note: shadowed declaration is here
    8 | ll N, K, L, x, ans;
      |       ^
boxes.cpp:11:37: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   11 | ll delivery(ll N, ll K, ll L, ll p[]) {
      |                                     ^
boxes.cpp:8:4: note: shadowed declaration is here
    8 | ll N, K, L, x, ans;
      |    ^
boxes.cpp:19:17: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   19 |  for (int i = N + 1; i; i--) {
      |               ~~^~~
/tmp/ccBJzgxl.o: In function `main':
grader.c:(.text.startup+0x1cb): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status