Submission #767719

#TimeUsernameProblemLanguageResultExecution timeMemory
767719The_SamuraiKućice (COCI21_kucice)C++17
0 / 110
2 ms468 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...