| Task: | Traffic jam |
| Sender: | aalto26am_035 |
| Submission time: | 2026-09-05 19:30:43 +0300 |
| Language: | C++ (C++23) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:17:14: error: 'for_each' is not a member of 'std'
17 | std::for_each(m.begin() + j, m.begin() + k + 1, [&](int &x) {
| ^~~~~~~~Code
#include <iostream>
#include <vector>
int main(int argc, char ** argv) {
int n;
std::cin >> n;
std::vector<int> m(604801, 0);
int max = 0;
int i = 0;
while (i < n) {
int j, k;
std::cin >> j >> k;
std::for_each(m.begin() + j, m.begin() + k + 1, [&](int &x) {
if (x + 1 > max)
max = x + 1;
x++;
});
i++;
}
std::cout << std::endl;
std::cout << max << std::endl;
return 0;
}