Submission #780179

#TimeUsernameProblemLanguageResultExecution timeMemory
780179andecaandeciKnapsack (NOI18_knapsack)C++17
73 / 100
1081 ms1228 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; const ll MAXN = 1e5 + 5; const ll MAXT = 2e3 + 5; ll n, t, li, ei, ki, dp[MAXT]; void update(ll a, ll b) { // {Spread, Energi} for (int i = t; i >= 0; --i) { if (i < b) { break; } dp[i] = max(dp[i], dp[i-b] + a); } } int main(){ cin >> t >> n; for (int i = 0; i < n; ++i) { cin >> li >> ei >> ki; ki = min(ki, t / ei); while(ki--) { update(li, ei); } } cout << dp[t] << "\n"; return 0; }
#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...