Submission #873333

#TimeUsernameProblemLanguageResultExecution timeMemory
873333Squar_HeadKnapsack (NOI18_knapsack)C++14
Compilation error
0 ms0 KiB
int main() { int n, x; cin >> n >> x; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; for (int i = 1; i <= n; i++) cin >> c[i]; auto cost = [&] (int i, int j, int k) { return dp[i - 1][k] + (j - k) / a[i] * b[i]; }; for (int i = 1; i <= n; i++) { for (int mod = 0; mod < a[i]; mod++) { deque<int> dq; for (int j = mod; j <= x; j += a[i]) { while (dq.size() && cost(i, j, j) >= cost(i, j, dq.back())) dq.pop_back(); dq.push_back(j); while (dq.size() && dq.front() < max(0ll, j - c[i] * a[i])) dq.pop_front(); dp[i][j] = cost(i, j, dq.front()); } } } cout << dp[n][x]; return 0; }

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> n >> x;
      |     ^~~
knapsack.cpp:5:41: error: 'a' was not declared in this scope
    5 |     for (int i = 1; i <= n; i++) cin >> a[i];
      |                                         ^
knapsack.cpp:6:41: error: 'b' was not declared in this scope
    6 |     for (int i = 1; i <= n; i++) cin >> b[i];
      |                                         ^
knapsack.cpp:7:41: error: 'c' was not declared in this scope
    7 |     for (int i = 1; i <= n; i++) cin >> c[i];
      |                                         ^
knapsack.cpp: In lambda function:
knapsack.cpp:9:13: error: 'dp' was not declared in this scope
    9 |      return dp[i - 1][k] + (j - k) / a[i] * b[i];
      |             ^~
knapsack.cpp:9:38: error: 'a' was not declared in this scope
    9 |      return dp[i - 1][k] + (j - k) / a[i] * b[i];
      |                                      ^
knapsack.cpp:9:45: error: 'b' was not declared in this scope
    9 |      return dp[i - 1][k] + (j - k) / a[i] * b[i];
      |                                             ^
knapsack.cpp: In function 'int main()':
knapsack.cpp:12:33: error: 'a' was not declared in this scope
   12 |         for (int mod = 0; mod < a[i]; mod++) {
      |                                 ^
knapsack.cpp:13:13: error: 'deque' was not declared in this scope
   13 |             deque<int> dq;
      |             ^~~~~
knapsack.cpp:13:19: error: expected primary-expression before 'int'
   13 |             deque<int> dq;
      |                   ^~~
knapsack.cpp:15:24: error: 'dq' was not declared in this scope
   15 |                 while (dq.size() && cost(i, j, j) >= cost(i, j, dq.back())) dq.pop_back();
      |                        ^~
knapsack.cpp:16:17: error: 'dq' was not declared in this scope
   16 |                 dq.push_back(j);
      |                 ^~
knapsack.cpp:17:63: error: 'c' was not declared in this scope
   17 |                 while (dq.size() && dq.front() < max(0ll, j - c[i] * a[i])) dq.pop_front();
      |                                                               ^
knapsack.cpp:17:50: error: 'max' was not declared in this scope
   17 |                 while (dq.size() && dq.front() < max(0ll, j - c[i] * a[i])) dq.pop_front();
      |                                                  ^~~
knapsack.cpp:18:17: error: 'dp' was not declared in this scope
   18 |                 dp[i][j] = cost(i, j, dq.front());
      |                 ^~
knapsack.cpp:22:5: error: 'cout' was not declared in this scope; did you mean 'cost'?
   22 |     cout << dp[n][x];
      |     ^~~~
      |     cost
knapsack.cpp:22:13: error: 'dp' was not declared in this scope
   22 |     cout << dp[n][x];
      |             ^~