제출 #1123213

#제출 시각아이디문제언어결과실행 시간메모리
1123213srp_8604Knapsack (NOI18_knapsack)C++20
37 / 100
1095 ms328 KiB
#include<bits/stdc++.h> using namespace std; #define endl "\n" #define int long long typedef long long ll; typedef long double lld; typedef unsigned long long ull; typedef long long ll; typedef vector<long long> vll; typedef vector<vector<long long>> vvll; typedef pair<ll, ll> pll; typedef vector<pll> vpll; #define F first #define S second #define PB push_back #define rep(i,a,b) for(ll i = a; i < b; i++) #define rrep(i,a,b) for(ll i = a; i >= b; i--) const lld pi = 3.14159265358979323846; const ll mod = 1000000007; const ll llmax=1e18; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout << fixed << setprecision(14); // ll t; cin>>t; ll t=1; while(t--){ ll s,n; cin>>s>>n; // vvll dp(n, vll(s+1,0)); vll dp(s+1,0); rep(i,0,n){ ll v,w,k; cin>>v>>w>>k; while(k--){ rrep(j, s, w){ dp[j] = max(dp[j], dp[j-w]+v); } } } cout<<dp[s]<<endl; } 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...