Submission #224469

#TimeUsernameProblemLanguageResultExecution timeMemory
224469DavidDamianBoxes with souvenirs (IOI15_boxes)C++11
Compilation error
0 ms0 KiB
#include "boxes.h" #include<bits/stdc++.h> #define debug(x) cout<<#x<<" = "<<x<<endl typedef long long ll; int A[1000007]; int n; int L; ll sumRange(int s,int len) { ll cost=0; int i=0; int id=0; while(i<len){ id=(i+s)%n; if(i==0) cost+=(ll)min(A[id],L-A[id]); else{ int dist=abs(A[id]-A[(id+n-1)%n]); cost+=(ll)min(dist,L-dist); } i++; } i--; id=(i+s)%n; cost+=(ll)min(A[id],L-A[id]); return cost; } long long delivery(int N, int k, int l, int p[]) { n=N; L=l; for(int i=0;i<n;i++){ A[i]=p[i]; } ll minimum=LLONG_MAX; for(int s=0;s<n;s++){ //For each possible start ll cost=0; if(n%k!=0) cost+=sumRange(s,n%k); for(int i=n%k;i<n;i+=k){ cost+=sumRange((s+i)%n,k); } minimum=min(minimum,cost); } return minimum; }

Compilation message (stderr)

boxes.cpp: In function 'll sumRange(int, int)':
boxes.cpp:16:23: error: 'min' was not declared in this scope
             cost+=(ll)min(A[id],L-A[id]);
                       ^~~
boxes.cpp:16:23: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
boxes.cpp:19:23: error: 'min' was not declared in this scope
             cost+=(ll)min(dist,L-dist);
                       ^~~
boxes.cpp:19:23: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
boxes.cpp:25:15: error: 'min' was not declared in this scope
     cost+=(ll)min(A[id],L-A[id]);
               ^~~
boxes.cpp:25:15: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:41:17: error: 'min' was not declared in this scope
         minimum=min(minimum,cost);
                 ^~~
boxes.cpp:41:17: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~