Submission #1032100

#TimeUsernameProblemLanguageResultExecution timeMemory
1032100SonicMLBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <algorithm> #include "boxes.h" using namespace std; typedef long long ll; int const NMAX = 1e7; ll preA[1 + NMAX]; ll preB[1 + NMAX]; vector <int> a; vector <int> b; int centre = 0; void buildPre(int k) { for(int i = 0;i < a.size() && i < k;i++) { preA[i] = 2 * a[i]; } for(int i = k;i < a.size();i++) { preA[i] = preA[i-k] + 2 * a[i]; } for(int i = 0;i < b.size() && i < k;i++) { preB[i] = 2 * b[i]; } for(int i = k;i < b.size();i++) { preB[i] = preB[i-k] + 2 * b[i]; } } ll delivery(int n, int k, int l, int positions[]) { //cerr << "Damn, not here\n"; for(int i = 0;i < n;i++) { int pos = positions[i]; if(l % 2 == 0 && pos == l / 2) { centre = pos; } else if(pos <= l / 2) { a.push_back(pos); } else { b.push_back(l - pos); } } //cerr << "Fourth Chaos Emerald\n"; sort(a.begin(), a.end()); sort(b.begin(), b.end()); buildPre(k); //cerr << "I am all of me!\n"; ll ans = preA[a.size()-1] + preB[b.size()-1]; int limA = a.size()-1, limB = b.size()-1; cerr << ans << '\n'; for(int round = 1;round < (n - 1) / k + 1;round++) { for(int j = 0;j < k;j++) { if(preA[limA] - preA[limA-1] < preB[limB] - preB[limB-1]) { limA--; } else { limB--; } } ll tans = 1LL * l * round + preA[limA] + preB[limB]; ans = min(ans, tans); } //cerr << "Just like taking candy from a baby, which is fine by me\n"; return ans; }

Compilation message (stderr)

boxes.cpp:13:1: error: 'vector' does not name a type
   13 | vector <int> a;
      | ^~~~~~
boxes.cpp:14:1: error: 'vector' does not name a type
   14 | vector <int> b;
      | ^~~~~~
boxes.cpp: In function 'void buildPre(int)':
boxes.cpp:18:21: error: 'a' was not declared in this scope
   18 |   for(int i = 0;i < a.size() && i < k;i++) {
      |                     ^
boxes.cpp:21:21: error: 'a' was not declared in this scope
   21 |   for(int i = k;i < a.size();i++) {
      |                     ^
boxes.cpp:24:21: error: 'b' was not declared in this scope
   24 |   for(int i = 0;i < b.size() && i < k;i++) {
      |                     ^
boxes.cpp:27:21: error: 'b' was not declared in this scope
   27 |   for(int i = k;i < b.size();i++) {
      |                     ^
boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:39:7: error: 'a' was not declared in this scope
   39 |       a.push_back(pos);
      |       ^
boxes.cpp:41:7: error: 'b' was not declared in this scope
   41 |       b.push_back(l - pos);
      |       ^
boxes.cpp:45:8: error: 'a' was not declared in this scope
   45 |   sort(a.begin(), a.end());
      |        ^
boxes.cpp:46:8: error: 'b' was not declared in this scope
   46 |   sort(b.begin(), b.end());
      |        ^
boxes.cpp:54:43: error: 'limB' was not declared in this scope; did you mean 'limA'?
   54 |       if(preA[limA] - preA[limA-1] < preB[limB] - preB[limB-1]) {
      |                                           ^~~~
      |                                           limA
boxes.cpp:60:51: error: 'limB' was not declared in this scope; did you mean 'limA'?
   60 |     ll tans = 1LL * l * round + preA[limA] + preB[limB];
      |                                                   ^~~~
      |                                                   limA