Task: | Card game |
Sender: | ivan |
Submission time: | 2016-09-17 14:24:29 +0300 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp:8:1: error: 'vector' does not name a type; did you mean 'perror'? vector<int> points; ^~~~~~ perror input/code.cpp:9:1: error: 'vector' does not name a type; did you mean 'perror'? vector<int> cost; ^~~~~~ perror input/code.cpp: In function 'int main(int, char**)': input/code.cpp:20:9: error: 'points' was not declared in this scope points.push_back(p); ^~~~~~ input/code.cpp:20:9: note: suggested alternative: 'printf' points.push_back(p); ^~~~~~ printf input/code.cpp:28:5: error: 'cost' was not declared in this scope cost.push_back(0); ^~~~ input/code.cpp:28:5: note: suggested alternative: 'pclose' cost.push_back(0); ^~~~ pclose input/code.cpp:30:20: error: 'points' was not declared in this scope cost.push_back(points[1]); ^~~~~~ input/code.cpp:30:20: note: suggested alternative: 'printf' cost.push_back(points[1]); ^~~~~~ printf...
Code
#include <iostream> #include <cstdio> #include <algorithm> #include <stack> using namespace std; vector<int> points; vector<int> cost; int main(int argc, char *argv[]) { ios::sync_with_stdio(0); int n = 0; cin >> n; for (int i = 0; i < n; ++i) { int p; cin >> p; points.push_back(p); } if (n == 1 || n == 2) { cout << 0 << endl; return 0; } cost.push_back(0); cost.push_back(0); cost.push_back(points[1]); for (int i = 3; i < n; ++i) { int cur_sum = points[i - 1] + cost[i - 3]; cost.push_back(max(cur_sum, cost[i - 1])); } // for (int i = 0; i < cost.size(); ++i) { // cout << cost[i] << endl; // } cout << cost[n - 1] << endl; return 0; }