Submission #1034343

#TimeUsernameProblemLanguageResultExecution timeMemory
1034343fv3Boxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1ll << 60; ll delivery(int N_, int K_, int L_, int p[]) { ll L = L_; ll N = N_; ll K = K_; vector<ll> v(N); for (int i = 0; i < N; i++) v[i] = p[i]; sort(v.begin(), v.end()); // Subtask 5: K <= 3000 // Solve with Dynamic Programming // Let DP_r[i] be the minimum time to deliver the first i // packages and go back to start while only going right // Let DP_l[i] be the minimum time to deliver the last i // packages and go back to start while only going left // Find the optimal place to stop going right vector<ll> DP_r(N + 1, INF), DP_l(N + 1, INF); DP_r[0] = 0; DP_l[N] = 0;    for (int i = 1; i <= N; i++) {      int last = max(0, i- K);      DP_r[i] = DP_r[last] + min(2*v[i-1], L);             }    for (int i = N - 1; i >= 0; i--) {      int next = min(i + K, N-1);      DP_l[i] = DP_l[next] + min((L - v[i]) * 2, L);      } ll res = INF; for (int i = 0; i <= N; i++) res = min(res, DP_r[i] + DP_l[i]); return res; }

Compilation message (stderr)

boxes.cpp:31:2: error: extended character   is not valid in an identifier
   31 |     for (int i = 1; i <= N; i++)
      |  ^
boxes.cpp:31:5: error: extended character   is not valid in an identifier
   31 |     for (int i = 1; i <= N; i++)
      |    ^
boxes.cpp:33:2: error: extended character   is not valid in an identifier
   33 |       int last = max(0, i- K);
      |  ^
boxes.cpp:33:5: error: extended character   is not valid in an identifier
   33 |       int last = max(0, i- K);
      |    ^
boxes.cpp:33:8: error: extended character   is not valid in an identifier
   33 |       int last = max(0, i- K);
      |      ^
boxes.cpp:34:2: error: extended character   is not valid in an identifier
   34 |       DP_r[i] = DP_r[last] + min(2*v[i-1], L);            
      |  ^
boxes.cpp:34:5: error: extended character   is not valid in an identifier
   34 |       DP_r[i] = DP_r[last] + min(2*v[i-1], L);            
      |    ^
boxes.cpp:34:8: error: extended character   is not valid in an identifier
   34 |       DP_r[i] = DP_r[last] + min(2*v[i-1], L);            
      |      ^
boxes.cpp:34:51: error: extended character   is not valid in an identifier
   34 |       DP_r[i] = DP_r[last] + min(2*v[i-1], L);            
      |                                                ^
boxes.cpp:34:54: error: extended character   is not valid in an identifier
   34 |       DP_r[i] = DP_r[last] + min(2*v[i-1], L);            
      |                                                  ^
boxes.cpp:34:57: error: extended character   is not valid in an identifier
   34 |       DP_r[i] = DP_r[last] + min(2*v[i-1], L);            
      |                                                    ^
boxes.cpp:34:60: error: extended character   is not valid in an identifier
   34 |       DP_r[i] = DP_r[last] + min(2*v[i-1], L);            
      |                                                      ^
boxes.cpp:34:63: error: extended character   is not valid in an identifier
   34 |       DP_r[i] = DP_r[last] + min(2*v[i-1], L);            
      |                                                        ^
boxes.cpp:34:66: error: extended character   is not valid in an identifier
   34 |       DP_r[i] = DP_r[last] + min(2*v[i-1], L);            
      |                                                          ^
boxes.cpp:37:2: error: extended character   is not valid in an identifier
   37 |     for (int i = N - 1; i >= 0; i--)
      |  ^
boxes.cpp:37:5: error: extended character   is not valid in an identifier
   37 |     for (int i = N - 1; i >= 0; i--)
      |    ^
boxes.cpp:39:2: error: extended character   is not valid in an identifier
   39 |       int next = min(i + K, N-1);
      |  ^
boxes.cpp:39:5: error: extended character   is not valid in an identifier
   39 |       int next = min(i + K, N-1);
      |    ^
boxes.cpp:39:8: error: extended character   is not valid in an identifier
   39 |       int next = min(i + K, N-1);
      |      ^
boxes.cpp:40:2: error: extended character   is not valid in an identifier
   40 |       DP_l[i] = DP_l[next] + min((L - v[i]) * 2, L);     
      |  ^
boxes.cpp:40:5: error: extended character   is not valid in an identifier
   40 |       DP_l[i] = DP_l[next] + min((L - v[i]) * 2, L);     
      |    ^
boxes.cpp:40:8: error: extended character   is not valid in an identifier
   40 |       DP_l[i] = DP_l[next] + min((L - v[i]) * 2, L);     
      |      ^
boxes.cpp:40:56: error: extended character   is not valid in an identifier
   40 |       DP_l[i] = DP_l[next] + min((L - v[i]) * 2, L);     
      |                                                     ^
boxes.cpp:40:59: error: extended character   is not valid in an identifier
   40 |       DP_l[i] = DP_l[next] + min((L - v[i]) * 2, L);     
      |                                                       ^
boxes.cpp:40:62: error: extended character   is not valid in an identifier
   40 |       DP_l[i] = DP_l[next] + min((L - v[i]) * 2, L);     
      |                                                         ^
boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:31:2: error: '\U000000a0' was not declared in this scope
   31 |     for (int i = 1; i <= N; i++)
      |  ^
boxes.cpp:31:23: error: 'i' was not declared in this scope
   31 |     for (int i = 1; i <= N; i++)
      |                     ^
boxes.cpp:37:4: error: expected ';' before '\U000000a0for'
   37 |     for (int i = N - 1; i >= 0; i--)
      |   ^~~~~
      |   ;
boxes.cpp:44:14: warning: declaration of 'i' shadows a previous local [-Wshadow]
   44 |     for (int i = 0; i <= N; i++)
      |              ^
boxes.cpp:31:23: note: shadowed declaration is here
   31 |     for (int i = 1; i <= N; i++)
      |                     ^
boxes.cpp:11:8: warning: unused variable 'L' [-Wunused-variable]
   11 |     ll L = L_; ll N = N_; ll K = K_;
      |        ^
boxes.cpp:11:30: warning: unused variable 'K' [-Wunused-variable]
   11 |     ll L = L_; ll N = N_; ll K = K_;
      |                              ^