Submission #767719

# Submission time Handle Problem Language Result Execution time Memory
767719 2023-06-27T05:46:55 Z The_Samurai Kućice (COCI21_kucice) C++17
0 / 110
2 ms 468 KB
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const ll inf = 1e18;

void solve() {
    int n, k;
    cin >> n >> k;
    assert(k == 1);
    vector<ll> dp(n + 1, inf);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        int w, d;
        cin >> w >> d;
        for (int j = d - 1; j >= 0; j--) {
            dp[j + 1] = min(dp[j + 1], dp[j] + w);
        }
    }
    for (int i = n; i > 0; i--) {
        if (dp[i] != inf) {
            cout << i << ' ' << dp[i];
            return;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    srand(time(0));

    int queries = 1;
#ifdef test_cases
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> queries;
#else
    //    cin >> queries;
#endif

    for (int test_case = 1; test_case <= queries; test_case++) {
        solve();
//        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -