CSES - Aalto Competitive Programming 2024 - wk1 - Mon - Results
Submission details
Task:Traffic jam
Sender:lehujber
Submission time:2024-09-02 16:34:50 +0300
Language:C++20
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:24:13: error: 'INT_MIN' was not declared in this scope
   24 |   int max = INT_MIN;
      |             ^~~~~~~
input/code.cpp:3:1: note: 'INT_MIN' is defined in header '<climits>'; did you forget to '#include <climits>'?
    2 | #include <map>
  +++ |+#include <climits>
    3 |

Code

#include <iostream>
#include <map>

using namespace std;
int main(int argc, char *argv[]) {
  int n;
  cin >> n;

  map<int, int> timeframes;

  for (int i = 0; i < n; ++i) {
    int start, end;
    cin >> start >> end;

    for (int j = start; j <= end; ++j) {
      if (timeframes.find(j) == timeframes.end()) {
        timeframes[j] = 0;
      }

      timeframes[j] += 1;
    }
  }

  int max = INT_MIN;
  int max_time = -1;

  for (const auto rec : timeframes) {
    if (max < rec.second) {
      max = rec.second;
      max_time = rec.first;
    }
  }

  cout << timeframes[max_time] << endl;

  return 0;
}