답안 #510920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
510920 2022-01-15T03:46:53 Z KoD Akcija (COCI21_akcija) C++17
30 / 110
36 ms 31684 KB
#include <bits/stdc++.h>

using std::vector;
using std::array;
using std::pair;
using std::tuple;

using i64 = std::int64_t;

constexpr i64 inf = std::numeric_limits<i64>::max() / 2;

void setmin(i64& x, const i64 y) {
    if (x > y) {
        x = y;
    }
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N, K;
    std::cin >> N >> K;
    vector<pair<int, int>> prod(N);
    for (auto& [d, w] : prod) {
        std::cin >> w >> d;
    }    
    std::sort(prod.begin(), prod.end());
    if (K == 1) {
        vector dp(N + 1, vector<i64>(N + 1, inf));
        setmin(dp[0][0], 0);
        for (int i = 0; i < N; ++i) {
            const auto& [d, w] = prod[i];
            for (int j = 0; j <= N; ++j) {
                if (dp[i][j] == inf) continue;
                if (d > j) {
                    setmin(dp[i + 1][j + 1], dp[i][j] + w);
                }
                setmin(dp[i + 1][j], dp[i][j]);
            }
        }
        int j = N;
        while (dp[N][j] == inf) {
            j -= 1;
        }
        std::cout << j << ' ' << dp[N][j] << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 29260 KB Output is correct
2 Correct 32 ms 31628 KB Output is correct
3 Correct 25 ms 26956 KB Output is correct
4 Correct 36 ms 26060 KB Output is correct
5 Correct 33 ms 31168 KB Output is correct
6 Correct 24 ms 26140 KB Output is correct
7 Correct 31 ms 31456 KB Output is correct
8 Correct 30 ms 27096 KB Output is correct
9 Correct 24 ms 25776 KB Output is correct
10 Correct 26 ms 27808 KB Output is correct
11 Correct 4 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 29260 KB Output is correct
2 Correct 32 ms 31628 KB Output is correct
3 Correct 25 ms 26956 KB Output is correct
4 Correct 36 ms 26060 KB Output is correct
5 Correct 33 ms 31168 KB Output is correct
6 Correct 24 ms 26140 KB Output is correct
7 Correct 31 ms 31456 KB Output is correct
8 Correct 30 ms 27096 KB Output is correct
9 Correct 24 ms 25776 KB Output is correct
10 Correct 26 ms 27808 KB Output is correct
11 Correct 4 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 26 ms 29164 KB Output is correct
15 Correct 32 ms 31684 KB Output is correct
16 Correct 33 ms 26852 KB Output is correct
17 Correct 31 ms 26180 KB Output is correct
18 Correct 25 ms 31180 KB Output is correct
19 Correct 26 ms 26056 KB Output is correct
20 Correct 33 ms 31344 KB Output is correct
21 Correct 22 ms 27064 KB Output is correct
22 Correct 21 ms 25732 KB Output is correct
23 Correct 29 ms 27908 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 29260 KB Output is correct
2 Correct 32 ms 31628 KB Output is correct
3 Correct 25 ms 26956 KB Output is correct
4 Correct 36 ms 26060 KB Output is correct
5 Correct 33 ms 31168 KB Output is correct
6 Correct 24 ms 26140 KB Output is correct
7 Correct 31 ms 31456 KB Output is correct
8 Correct 30 ms 27096 KB Output is correct
9 Correct 24 ms 25776 KB Output is correct
10 Correct 26 ms 27808 KB Output is correct
11 Correct 4 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 26 ms 29164 KB Output is correct
15 Correct 32 ms 31684 KB Output is correct
16 Correct 33 ms 26852 KB Output is correct
17 Correct 31 ms 26180 KB Output is correct
18 Correct 25 ms 31180 KB Output is correct
19 Correct 26 ms 26056 KB Output is correct
20 Correct 33 ms 31344 KB Output is correct
21 Correct 22 ms 27064 KB Output is correct
22 Correct 21 ms 25732 KB Output is correct
23 Correct 29 ms 27908 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 320 KB Output is correct
27 Incorrect 1 ms 204 KB Output isn't correct
28 Halted 0 ms 0 KB -