답안 #767766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767766 2023-06-27T07:04:39 Z drdilyor Akcija (COCI21_akcija) C++17
10 / 110
65 ms 63192 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

    int n, k;
    cin >> n >> k;
    vector<pair<int,int>> arr(n);
    for (auto&[d, cost] : arr) cin >> cost >> d;
    // assert(k == 1);

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

    vector memo(n, vector(n+1, pair{-1, 0ll}));
    auto dp = [&](auto& dp, int i, int t)->pair<int,ll> {
        if (i < 0 || t <= 0) return {0, 0};
        if (memo[i][t].first != -1) return memo[i][t];
        auto res = dp(dp, i-1, t-1);
        if (arr[i].first >= t) {
            auto [cnt, cost] = dp(dp, i-1, t-1);
            cnt++;
            cost -= arr[i].second;
            res = max(res, {cnt, cost});
        }
        return memo[i][t] = res;
    };

    pair<int,ll> res = {0, 0};
    for (int i = 1; i <= n; i++) {
        res = max(res, dp(dp, n-1, i));
    }

    cout << res.first << ' ' << -res.second << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 58216 KB Output is correct
2 Correct 64 ms 63192 KB Output is correct
3 Correct 53 ms 53388 KB Output is correct
4 Correct 52 ms 51980 KB Output is correct
5 Correct 60 ms 61928 KB Output is correct
6 Correct 48 ms 51924 KB Output is correct
7 Correct 58 ms 62556 KB Output is correct
8 Correct 42 ms 53836 KB Output is correct
9 Correct 46 ms 51360 KB Output is correct
10 Correct 65 ms 55428 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 58216 KB Output is correct
2 Correct 64 ms 63192 KB Output is correct
3 Correct 53 ms 53388 KB Output is correct
4 Correct 52 ms 51980 KB Output is correct
5 Correct 60 ms 61928 KB Output is correct
6 Correct 48 ms 51924 KB Output is correct
7 Correct 58 ms 62556 KB Output is correct
8 Correct 42 ms 53836 KB Output is correct
9 Correct 46 ms 51360 KB Output is correct
10 Correct 65 ms 55428 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Incorrect 58 ms 58188 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 58220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 58216 KB Output is correct
2 Correct 64 ms 63192 KB Output is correct
3 Correct 53 ms 53388 KB Output is correct
4 Correct 52 ms 51980 KB Output is correct
5 Correct 60 ms 61928 KB Output is correct
6 Correct 48 ms 51924 KB Output is correct
7 Correct 58 ms 62556 KB Output is correct
8 Correct 42 ms 53836 KB Output is correct
9 Correct 46 ms 51360 KB Output is correct
10 Correct 65 ms 55428 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Incorrect 58 ms 58188 KB Output isn't correct
15 Halted 0 ms 0 KB -