CSES - Aalto Competitive Programming 2024 - wk1 - Mon - Results
Submission details
Task:Traffic jam
Sender:htoik
Submission time:2024-09-02 17:19:42 +0300
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:15:5: error: 'inline' specifier invalid for variable 'dens' declared at block scope
   15 |     inline auto dens = [&](int x2){
      |     ^~~~~~

Code

#include <iostream>
#include <map>
#include <algorithm>

inline auto ininterval = [](int x, int a, int b){
    return (x >= a && x <= b);
};

int main(){
    int n;

    std::cin >> n;
    std::vector<int> is(2*n,0);

    inline auto dens = [&](int x2){
        int c = 0;
        for(int i=0; i<n; i++){
            c += ininterval(x2, is[i], is[n+i]);
        }
        return c;
    };

    for(int x=0; x<n; x++){
        int i, j;
        std::cin >> i >> j;
        is[x] = i;
        is[x+n] = j;
    }

    int maxdens = 0;
    for(const auto& x : is){
        maxdens = std::max(maxdens, dens(x));
    }

    std::cout << maxdens << std::endl;
}