Task: | Karuselli |
Sender: | ankka22 |
Submission time: | 2017-03-06 18:09:44 +0200 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:17:11: error: 'm1' was not declared in this scope cin >> m1[a]; ^ input/code.cpp:20:11: error: 'm2' was not declared in this scope cin >> m2[a]; ^ input/code.cpp:25:8: error: 'm1' was not declared in this scope if (m1[a] + m2[0] < p) break; ^ input/code.cpp:25:16: error: 'm2' was not declared in this scope if (m1[a] + m2[0] < p) break; ^ input/code.cpp:28:13: error: 'm1' was not declared in this scope p = max(m1[a] + m2[b], p); ^ input/code.cpp:28:21: error: 'm2' was not declared in this scope p = max(m1[a] + m2[b], p); ^ input/code.cpp:33:1: error: expected '}' at end of input }//:D ^
Code
#include <iostream> #include <vector> #include <map> using namespace std; long n, m, o, p, k; map<long, int> ma1, ma2; int main() { cin >> n >> k; //for (int i = 1; i <= n; i++) { if (n == 1) { for (int a = 1; a <= k; a++) { cin >> o; p = max(p, o); } } else { for (int a = 1; a <= k; a++) { cin >> m1[a]; } for (int a = 1; a <= k; a++) { cin >> m2[a]; } //v[i].push_back({a, i}); for (int a = 1; a <= k; a++) { if (m1[a] + m2[0] < p) break; for (int b = 1; b <= k; b++) { if (a == b) continue; p = max(m1[a] + m2[b], p); } } cout << p << endl; }//:D