Submission details
Task:Traffic jam
Sender:Dereden
Submission time:2025-09-01 16:41:34 +0300
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:7:3: error: 'vector' was not declared in this scope
    7 |   vector<pair<int, int>> times;
      |   ^~~~~~
input/code.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
input/code.cpp:7:23: error: expected primary-expression before '>' token
    7 |   vector<pair<int, int>> times;
      |                       ^~
input/code.cpp:7:26: error: 'times' was not declared in this scope; did you mean 'timex'?
    7 |   vector<pair<int, int>> times;
      |                          ^~~~~
      |                          timex
input/code.cpp:16:10: error: expected primary-expression before 'int'
   16 |   vector<int> cars(604801);
      |          ^~~
input/code.cpp:21:7: error: 'cars' was not declared in this scope
   21 |       cars[i] += 1;
      |       ^~~~
input/code.cpp:26:20: error: 'cars' was not declared in this scop...

Code

#include <iostream>

using namespace std;

int main() {
  int n;
  vector<pair<int, int>> times;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int start, end;
    cin >> start >> end;
    times.push_back(make_pair(start, end));
  }

  vector<int> cars(604801);
  for (const auto &time : times) {
    int l = time.first;
    int r = time.second;
    for (int i = l; i <= r; i++) {
      cars[i] += 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 604800; i++) {
    ans = max(ans, cars[i]);
  }
  cout << ans;
}