Submission #529957

#TimeUsernameProblemLanguageResultExecution timeMemory
529957antonioqbabBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> //#include <delivery.h> using namespace std; using ll = long long; int delivery(int n, int k, int l, int a[]){ ll ans = INT_MAX; vector<ll> dpl(n+2), dpr(n+2); for(int i=1;i<=n;++i) dpl[i]= dpl[max(i-k,0)] + 2*a[i-1]; for(int i=n;i;--i) dpr[i]= dpr[min(i+k,n+1)] + 2*(l-a[i-1]); for(int i=1;i<=n;++i) ans=min(ans, dpl[i]+dpr[i+1]-l); return ans; } int main(){ int n,k,l; cin >> n >> k >> l; int *v=new int[n]; for(int i=0;i<n;++i) cin >> v[i]; cout << delivery(n,k,l,v); }

Compilation message (stderr)

boxes.cpp: In function 'int delivery(int, int, int, int*)':
boxes.cpp:10:14: error: 'INT_MAX' was not declared in this scope
   10 |     ll ans = INT_MAX;
      |              ^~~~~~~
boxes.cpp:4:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 | //#include <delivery.h>
boxes.cpp:18:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   18 |     return ans;
      |            ^~~