Submission #729045

#TimeUsernameProblemLanguageResultExecution timeMemory
729045kirakaminski968Boxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int *positions[]){ long long ans = 0; vector<long long> p; p.push_back(0); for(auto c : positions) p.push_back(c); long long pref[N + 2], suf[N + 2]; pref[0] = suf[N+1] = 0; for(int i = 1;i <= N;++i) { pref[i] = (i<=K) ? a[i] * 2LL : p[i] * 2LL + pref[i - K]; } for(int i = N;i>=1;--i) { suf[i] =(i+K-1>N) ? (L-p[i]) * 2LL : (L-a[i]) * 2LL + suf[i+K]; } long long ans = suf[1]; for(int i = 0; i <= N; i++) { ans = min(ans,pref[i] + suf[i + 1]); if(i+K <= N) ans = min(ans,pref[i]+L+suf[i + K + 1]); else ans = min(ans, pref[i] + L); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int**)':
boxes.cpp:6:18: error: 'begin' was not declared in this scope
    6 |     for(auto c : positions) p.push_back(c);
      |                  ^~~~~~~~~
boxes.cpp:6:18: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from boxes.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
boxes.cpp:6:18: error: 'end' was not declared in this scope
    6 |     for(auto c : positions) p.push_back(c);
      |                  ^~~~~~~~~
boxes.cpp:6:18: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from boxes.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
boxes.cpp:11:28: error: 'a' was not declared in this scope
   11 |         pref[i] = (i<=K) ? a[i] * 2LL : p[i] * 2LL + pref[i - K];
      |                            ^
boxes.cpp:15:49: error: 'a' was not declared in this scope
   15 |         suf[i] =(i+K-1>N) ? (L-p[i]) * 2LL : (L-a[i]) * 2LL + suf[i+K];
      |                                                 ^
boxes.cpp:17:15: error: redeclaration of 'long long int ans'
   17 |     long long ans = suf[1];
      |               ^~~
boxes.cpp:4:15: note: 'long long int ans' previously declared here
    4 |     long long ans = 0;
      |               ^~~