Submission #1310630

#TimeUsernameProblemLanguageResultExecution timeMemory
1310630quollcucumber`Autobahn (COI21_autobahn)C++20
20 / 100
2 ms576 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n, k, x;
    cin >> n >> k >> x;
    vector<pair<int, int>> v;
    int people[1005];
    for(int i = 0; i < n ; i++) {
        int l, t, r;
        cin >> l>> t >> r;
        for(int j = l; j <= r; j++) people[j] ++;
        l += t;
        if(r >= l) {
            v.push_back({l, r});
        }
    }
    int naughtypeople[1005];
    for(pair<int, int> i : v) {
        for(int j = i.first; j<= i.second; j++) naughtypeople[j]++;
    }
    int maxval = 0;
    int total = 0;
    for(int i = 0; i < x; i++) {
        if(people[i] >= k) {
            total += naughtypeople[i];
        }
    }
    maxval = total;
    for(int i = x; i < 1005; i++) {
        if(people[i] >= k) {
            total += naughtypeople[i];
        }
        if(people[i-x] >= k) {
            total -= naughtypeople[i-x];
        }
        maxval = max(maxval, total);
    }
    cout<<maxval<<'\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...