Submission #1023660

#TimeUsernameProblemLanguageResultExecution timeMemory
1023660vjudge1Knapsack (NOI18_knapsack)C++17
37 / 100
1060 ms460 KiB
#include <bits/stdc++.h> #include <vector> using namespace std; #define int long long #define ff first #define ss second #define tobit(n) bitset<20>(n) //выводит 20 элементов в битовую систему #define all(v) (v).begin(), (v).end() #define rtt(v, k) rotate(v.begin(), v.begin() + k, v.end()); //move k elements back const int MOD = 1e9 + 7; int binpownm(int n, int m){ if(m == 1) return n; if(m % 2 == 0){ int t = binpownm(n, m / 2); return t * t; } else return binpownm(n, m - 1) * n; } bool sortt(pair<int, double> a, pair<int, double> b){ return a.ss < b.ss; } struct sturc_t { int ff_, ss_, tt_; }; int knapsack(vector<sturc_t>& v, int S){ vector<int> dp(S + 1, 0); for(auto& to : v){ for(int q = 0; q < to.tt_; q++){ for(int w = S; w >= to.ss_; w--){ dp[w] = max(dp[w], dp[w - to.ss_] + to.ff_); } } } return dp[S]; } signed main(){ int n, s; cin >> n >> s; vector<sturc_t> v(s); for(int i = 0; i < s; i++){ cin >> v[i].ff_ >> v[i].ss_ >> v[i].tt_; } cout << knapsack(v, n); } // NEED TO FAST CIN && COUT // const int fastIO = [](){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 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...