답안 #1052283

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1052283 2024-08-10T13:00:59 Z VMaksimoski008 Autobahn (COI21_autobahn) C++17
100 / 100
115 ms 12988 KB
#include <bits/stdc++.h>
//#define int long long

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;

signed main() {
    int n, k, x;
    ll ans = 0;
    cin >> n >> k >> x;

    vector<array<int, 2> > v;
    for(int i=0; i<n; i++) {
        int l, t, r;
        cin >> l >> t >> r;
        v.push_back({ l, 0 });
        v.push_back({ l + t, 1 });
        v.push_back({ r + 1, 2 });
        v.push_back({ l + x, 3 });
        v.push_back({ l + t + x, 4 });
        v.push_back({ r + x + 1, 5 });
    }

    sort(v.begin(), v.end());

    ll prv=-1, st=0, ed=0, curr=0, chargeSt=0, chargeEd=0;
    for(auto &[t, type] : v) {
        ll coef = 0;
        if(st >= k) coef += chargeSt;
        if(ed >= k) coef -= chargeEd;
        curr += coef * (t - prv);

        if(type == 0) st++;
        if(type == 1) chargeSt++;
        if(type == 2) st--, chargeSt--;
        if(type == 3) ed++;
        if(type == 4) chargeEd++;
        if(type == 5) ed--, chargeEd--;

        ans = max(ans, curr);
        prv = t;
    }

    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 556 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 556 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 108 ms 12624 KB Output is correct
22 Correct 108 ms 11760 KB Output is correct
23 Correct 106 ms 12988 KB Output is correct
24 Correct 115 ms 12048 KB Output is correct
25 Correct 111 ms 11972 KB Output is correct
26 Correct 105 ms 11276 KB Output is correct
27 Correct 106 ms 11444 KB Output is correct
28 Correct 107 ms 12460 KB Output is correct
29 Correct 106 ms 11700 KB Output is correct