답안 #1003576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003576 2024-06-20T13:12:41 Z ThegeekKnight16 Autobahn (COI21_autobahn) C++17
100 / 100
721 ms 94668 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K, X;
    cin >> N >> K >> X;
    vector<tuple<int, int, int>> sweep;
    set<int> vals;
    for (int i = 0; i < N; i++)
    {
        int L, T, R;
        cin >> L >> T >> R;
        T = min(L+T-1, R);
        sweep.emplace_back(L, 0, -1); vals.insert(L);
        sweep.emplace_back(T+1, 1, -1); vals.insert(T+1);
        sweep.emplace_back(R+1, 2, -1); vals.insert(R+1);
        sweep.emplace_back(T, 4, 3*i); sweep.emplace_back(T+X, 5, 3*i); vals.insert(T); vals.insert(T+X);
        sweep.emplace_back(R-X, 4, 3*i + 1); sweep.emplace_back(R, 5, 3*i + 1); vals.insert(R-X); vals.insert(R);
        sweep.emplace_back(L-1, 4, 3*i + 2); sweep.emplace_back(L+X-1, 5, 3*i + 2); vals.insert(L-1); vals.insert(L+X-1);
    }
    for (auto x : vals) sweep.emplace_back(x, 3, -1);
    vector<int> possResp(3*N);
    sort(sweep.begin(), sweep.end());
    int totPeople = 0, totPaying = 0, totPay = 0, lastX = 0, resp = 0;
    for (auto [x, type, id] : sweep)
    {
        // cerr << "x: " << x << ", totPeople: " << totPeople << ", totPaying: " << totPaying << ", totPay: " << totPay << '\n';
        if (type == 0) totPeople++;
        else if (type == 1) totPaying++;
        else if (type == 2) totPeople--, totPaying--;
        else if (type == 3)
        {
            totPay += (int)(totPeople >= K) * totPaying * (x - lastX);
            lastX = x;
        }
        else if (type == 4) possResp[id] = totPay;
        else resp = max(resp, totPay - possResp[id]);
    }
    cout << resp << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 344 KB Output is correct
6 Correct 0 ms 348 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 348 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 1 ms 348 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 344 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 828 KB Output is correct
13 Correct 2 ms 832 KB Output is correct
14 Correct 2 ms 944 KB Output is correct
15 Correct 2 ms 836 KB Output is correct
16 Correct 2 ms 896 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 2 ms 900 KB Output is correct
19 Correct 2 ms 900 KB Output is correct
20 Correct 2 ms 908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 344 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 828 KB Output is correct
13 Correct 2 ms 832 KB Output is correct
14 Correct 2 ms 944 KB Output is correct
15 Correct 2 ms 836 KB Output is correct
16 Correct 2 ms 896 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 2 ms 900 KB Output is correct
19 Correct 2 ms 900 KB Output is correct
20 Correct 2 ms 908 KB Output is correct
21 Correct 645 ms 94616 KB Output is correct
22 Correct 666 ms 94460 KB Output is correct
23 Correct 631 ms 94644 KB Output is correct
24 Correct 703 ms 94644 KB Output is correct
25 Correct 693 ms 94484 KB Output is correct
26 Correct 670 ms 94668 KB Output is correct
27 Correct 686 ms 94588 KB Output is correct
28 Correct 721 ms 94660 KB Output is correct
29 Correct 654 ms 94616 KB Output is correct