Task: | Cow heist |
Sender: | aalto2024b_009 |
Submission time: | 2024-09-11 17:47:57 +0300 |
Language: | C++ (C++11) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp:5:6: error: 'list' in namespace 'std' does not name a template type 5 | std::list<int> sums(std::list<int> X, int target) { | ^~~~ input/code.cpp:4:1: note: 'std::list' is defined in header '<list>'; did you forget to '#include <list>'? 3 | #include <queue> +++ |+#include <list> 4 | input/code.cpp:11:43: error: 'std::list' has not been declared 11 | bool is_constructible_by_sum(int nb, std::list<int> X, int offset) { | ^~~~ input/code.cpp:11:47: error: expected ',' or '...' before '<' token 11 | bool is_constructible_by_sum(int nb, std::list<int> X, int offset) { | ^ input/code.cpp: In function 'bool is_constructible_by_sum(int, int)': input/code.cpp:12:9: error: 'X' was not declared in this scope 12 | if (X.size() == 1) { | ^ input/code.cpp:15:15: error: 'list' is not a member of 'std' 15 | for (std::list<int>::i...
Code
// Online C++ compiler to run C++ program online #include <iostream> #include <queue> std::list<int> sums(std::list<int> X, int target) { if (X.size == 1) return X[0]; for () } bool is_constructible_by_sum(int nb, std::list<int> X, int offset) { if (X.size() == 1) { return X[0] == nb; } for (std::list<int>::iterator it = X.begin(); it != X.end(); ++it) { } } int main(int argc, char *argv[]) { int n = atoi(argv[1]); int c[n]; for (int i = 0; i < n; ++i) { c[i] = atoi(argv[i+2]); } std::map<int, int> ships; // <cows capacity, number of ships> int X[30]; int sum = 0; int l = 0; std::list<int> X_list (std::begin(X), std::end(X)); for (int i = 1; i < n; i++) { cows = c[i]; if (cows > sum) { X[l] = cows - sum; l++; } else { } } return 0; }