CSES - Aalto Competitive Programming 2024 - wk2 - Wed - Results
Submission details
Task:Binge watching
Sender:aalto2024b_003
Submission time:2024-09-11 16:22:13 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:66:34: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
   66 |     sort(a.begin(), a.end(), [&](auto u, auto v) {
      |                                  ^~~~
input/code.cpp:66:42: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
   66 |     sort(a.begin(), a.end(), [&](auto u, auto v) {
      |                                          ^~~~
input/code.cpp: In lambda function:
input/code.cpp:67:18: error: request for member 'second' in 'u', which is of non-class type 'int'
   67 |         return u.second < v.second;
      |                  ^~~~~~
input/code.cpp:67:29: error: request for member 'second' in 'v', which is of non-class type 'int'
   67 |         return u.second < v.second;
      |                             ^~~~~~
In file included from /usr/include/c++/11/bits/stl_algobase.h:71,
                 from /usr/...

Code

#include <bits/stdc++.h>
using namespace std;
#define int long long

string to_string(string s) {
    return '"' + s + '"';
}
 
string to_string(const char* s) {
    return to_string((string) s);
}
 
string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
 
void debug_out() {
    cerr << endl;
}
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 2e5 + 5;

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    int n;
    cin >> n;

    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }

    sort(a.begin(), a.end(), [&](auto u, auto v) {
        return u.second < v.second;
    });

    int ans = 0;
    int cur = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i].first >= cur) {
            ans++;
            cur = a[i].second;
        }
    }

    cout << ans << '\n';
}