답안 #652406

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
652406 2022-10-22T13:38:57 Z longvu Autobahn (COI21_autobahn) C++14
50 / 100
35 ms 7968 KB
/**
 *    author:  longvu
 *    created: 10/22/22 20:08:25
**/
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
const int INF = numeric_limits<int>::max();
const int nax = (int)(100001);
const int mod = 1e9 + 7;

template<class X, class Y>
bool maximize(X& x, const Y y) {
    if (y > x) {x = y; return true;}
    return false;
}
template<class X, class Y>
bool minimize(X& x, const Y y) {
    if (y < x) {x = y; return true;}
    return false;
}

int n, k, x;
int L[nax], T[nax], R[nax], pre[nax], prep[nax];
int sub1() {
    pre[0] = 0;
    for (int i = 1; i <= n; ++i) {
        pre[L[i]]++;
        pre[R[i] + 1]--;
    }
    for (int i = 1; i < nax; ++i) {
        pre[i] += pre[i - 1];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = L[i] + T[i]; j <= R[i]; ++j) {
            if (pre[j] >= k) {
                prep[j]++;
            }
        }
    }
    for (int i = 1; i < nax; ++i) {
        prep[i] += prep[i - 1];
    }
    int ans = 0;
    for (int i = 1; i + x - 1 < nax; ++i) {
        maximize(ans, prep[i + x - 1] - prep[i - 1]);
    }
    return ans;
}

const bool sub = 1;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k >> x;
    bool flag_sub1 = 1;
    for (int i = 1; i <= n; ++i) {
        cin >> L[i] >> T[i] >> R[i];
        if (L[i] > 1000 || T[i] > 1000 || R[i] > 1000) {
            flag_sub1 = 0;
        }
    }
    if (n <= 1000 && k <= 1000 && x <= 1000 && flag_sub1) {
        if (!sub) cout << "Sub1: " << '\n';
        cout << sub1() << '\n';
        if (sub) return 0;
    }
    assert(false);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 2 ms 1876 KB Output is correct
4 Correct 2 ms 1864 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 2 ms 1872 KB Output is correct
7 Correct 2 ms 1876 KB Output is correct
8 Correct 2 ms 1876 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 2 ms 1876 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 2 ms 1876 KB Output is correct
4 Correct 2 ms 1864 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 2 ms 1872 KB Output is correct
7 Correct 2 ms 1876 KB Output is correct
8 Correct 2 ms 1876 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 2 ms 1876 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
12 Correct 2 ms 1876 KB Output is correct
13 Correct 3 ms 1880 KB Output is correct
14 Correct 3 ms 1876 KB Output is correct
15 Correct 3 ms 1892 KB Output is correct
16 Correct 3 ms 1876 KB Output is correct
17 Correct 4 ms 1876 KB Output is correct
18 Correct 2 ms 1876 KB Output is correct
19 Correct 3 ms 1876 KB Output is correct
20 Correct 3 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 2 ms 1876 KB Output is correct
4 Correct 2 ms 1864 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 2 ms 1872 KB Output is correct
7 Correct 2 ms 1876 KB Output is correct
8 Correct 2 ms 1876 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 2 ms 1876 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
12 Correct 2 ms 1876 KB Output is correct
13 Correct 3 ms 1880 KB Output is correct
14 Correct 3 ms 1876 KB Output is correct
15 Correct 3 ms 1892 KB Output is correct
16 Correct 3 ms 1876 KB Output is correct
17 Correct 4 ms 1876 KB Output is correct
18 Correct 2 ms 1876 KB Output is correct
19 Correct 3 ms 1876 KB Output is correct
20 Correct 3 ms 1876 KB Output is correct
21 Runtime error 35 ms 7968 KB Execution killed with signal 6
22 Halted 0 ms 0 KB -