Submission #567891

#TimeUsernameProblemLanguageResultExecution timeMemory
567891Trisanu_DasBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namepspace std; #define int long long int int delivery(int n, int k, int l, int a){ int dp1[n + 1], dp2[n + 1], pos[n + 1]; dp1[0] = 0; dp2[0] = 0; for(int i = 0; i < n; i++) pos[i + 1] = a[i]; sort(a + 1, a + n + 1); for(int i = 1; i <= n ; i++){ dp1[i] = dp1[max(0, i - k)] + 2 * pos[i]; } for(int i = 1; i <= n ; i++){ dp2[i] = 2 * (l - pos[i]) + dp2[min(n + 1, i + k)]; } int ans = 1e18; for (int i = 1;i < n + 1;i++) ans = min(ans, dp1[i - 1] + dp2[i]); for (int i = k;i <= n;i++) ans = min(ans, dp[i - k] + dp2[i + 1] + l); return ans; }

Compilation message (stderr)

boxes.cpp:2:7: error: expected nested-name-specifier before 'namepspace'
    2 | using namepspace std;
      |       ^~~~~~~~~~
boxes.cpp: In function 'long long int delivery(long long int, long long int, long long int, long long int)':
boxes.cpp:7:44: error: invalid types 'long long int[long long int]' for array subscript
    7 |   for(int i = 0; i < n; i++) pos[i + 1] = a[i];
      |                                            ^
boxes.cpp:8:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
    8 |   sort(a + 1, a + n + 1);
      |   ^~~~
      |   std::sort
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
boxes.cpp:10:18: error: 'max' was not declared in this scope; did you mean 'std::max'?
   10 |     dp1[i] = dp1[max(0, i - k)] + 2 * pos[i];
      |                  ^~~
      |                  std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
boxes.cpp:13:37: error: 'min' was not declared in this scope; did you mean 'std::min'?
   13 |     dp2[i] = 2 * (l - pos[i]) + dp2[min(n + 1, i + k)];
      |                                     ^~~
      |                                     std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
boxes.cpp:16:39: error: 'min' was not declared in this scope; did you mean 'std::min'?
   16 |   for (int i = 1;i < n + 1;i++) ans = min(ans, dp1[i - 1] + dp2[i]);
      |                                       ^~~
      |                                       std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
boxes.cpp:17:45: error: 'dp' was not declared in this scope; did you mean 'dp2'?
   17 |   for (int i = k;i <= n;i++) ans = min(ans, dp[i - k] + dp2[i + 1] + l);
      |                                             ^~
      |                                             dp2
boxes.cpp:17:36: error: 'min' was not declared in this scope; did you mean 'std::min'?
   17 |   for (int i = k;i <= n;i++) ans = min(ans, dp[i - k] + dp2[i + 1] + l);
      |                                    ^~~
      |                                    std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~