Submission #1188301

#TimeUsernameProblemLanguageResultExecution timeMemory
1188301alwaus424Knapsack (NOI18_knapsack)C++20
Compilation error
0 ms0 KiB
void always424() { int s, n; cin >> s >> n; vector<tuple<int, int, int>> v(n); for (int i = 0; i < n; i++) { int a, b, c; cin >> a >> b >> c; v[i] = make_tuple(a, b, c); } ll tot = 0; // Start from zero weight ll ans = 0; int cost = get<0>(v[0]); int weight = get<1>(v[0]); int quantity = get<2>(v[0]); while (quantity > 0 && tot + weight <= s) { tot += weight; ans += cost; quantity--; } cout << ans << '\n'; }

Compilation message (stderr)

knapsack.cpp: In function 'void always424()':
knapsack.cpp:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> s >> n;
      |     ^~~
knapsack.cpp:4:12: error: 'tuple' was not declared in this scope
    4 |     vector<tuple<int, int, int>> v(n);
      |            ^~~~~
knapsack.cpp:4:5: error: 'vector' was not declared in this scope
    4 |     vector<tuple<int, int, int>> v(n);
      |     ^~~~~~
knapsack.cpp:4:18: error: expected primary-expression before 'int'
    4 |     vector<tuple<int, int, int>> v(n);
      |                  ^~~
knapsack.cpp:9:9: error: 'v' was not declared in this scope
    9 |         v[i] = make_tuple(a, b, c);
      |         ^
knapsack.cpp:9:16: error: 'make_tuple' was not declared in this scope
    9 |         v[i] = make_tuple(a, b, c);
      |                ^~~~~~~~~~
knapsack.cpp:12:5: error: 'll' was not declared in this scope
   12 |     ll tot = 0;   // Start from zero weight
      |     ^~
knapsack.cpp:13:7: error: expected ';' before 'ans'
   13 |     ll ans = 0;
      |       ^~~~
      |       ;
knapsack.cpp:15:23: error: 'v' was not declared in this scope
   15 |     int cost = get<0>(v[0]);
      |                       ^
knapsack.cpp:15:16: error: 'get' was not declared in this scope
   15 |     int cost = get<0>(v[0]);
      |                ^~~~~~
knapsack.cpp:19:28: error: 'tot' was not declared in this scope
   19 |     while (quantity > 0 && tot + weight <= s) {
      |                            ^~~
knapsack.cpp:21:9: error: 'ans' was not declared in this scope
   21 |         ans += cost;
      |         ^~~
knapsack.cpp:25:5: error: 'cout' was not declared in this scope; did you mean 'cost'?
   25 |     cout << ans << '\n';
      |     ^~~~
      |     cost
knapsack.cpp:25:13: error: 'ans' was not declared in this scope
   25 |     cout << ans << '\n';
      |             ^~~