| 14874 | 2025-02-05 17:15:42 | PKB | Érdekes túra (70 pont) | cpp17 | Compilation error |
#include <iostream>
#include <vector>
using namespace std;
int main() {
int hossz;
cin >> hossz;
vector<int> altitudes(hossz);
for (int i = 0; i < hossz; i++) {
cin >> altitudes[i];
}
int erdekes_turak = 0;
int max_hossz = 0;
int jelenlegi_hossz = 1; //akutalis tura hossz
for (int i = 1; i < hossz; i++) {
if (altitudes[i] != altitudes[i - 1]) {
jelenlegi_hossz++;
} else {
if (jelenlegi_hossz > 1) {
erdekes_turak++;
max_hossz = max(max_hossz, jelenlegi_hossz);
}
jelenlegi_hossz = 1; //uj tura
}
}
//utolso tura
if (jelenlegi_hossz > 1) {
erdekes_turak++;
max_hossz = max(max_hossz, jelenlegi_hossz);
}
cout << "\n"
cout << erdekes_turak << endl;
if (erdekes_turak == 0) {
cout << "-1" << endl;
} else {
cout << max_hossz << endl;
}
return 0;
}
open /var/local/lib/isolate/408/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:37:17: error: expected ';' before 'cout'
37 | cout << "\n"
| ^
| ;
38 |
39 | cout << erdekes_turak << endl;
| ~~~~