| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1307042 | ng.annhaat | Knapsack (NOI18_knapsack) | C++20 | 1095 ms | 580 KiB |
/*
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░ ░░░░░░░░ ░░░░░ ░ ░ ░░░░ ░░░░░ ░░░░░░ ░░░░
▒▒▒▒▒▒ ▒ ▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒ ▒▒▒ ▒▒▒▒ ▒▒▒ ▒▒▒▒ ▒▒
▒▒▒▒▒ ▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒ ▒ ▒▒▒▒▒▒▒▒ ▒ ▒▒▒▒ ▒▒
▓▓▓▓ ▓▓▓ ▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓ ▓▓▓▓▓▓▓▓ ▓ ▓ ▓▓▓▓▓▓
▓▓▓ ▓ ▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓ ▓ ▓▓▓▓▓▓▓▓ ▓ ▓▓ ▓▓▓▓
▓▓ ▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓ ▓▓▓ ▓▓▓▓▓ ▓▓ ▓▓▓▓ ▓▓
█ █████████ ███ ████████ █████ ████ █████ ██████ ██████
███████████████████████████████████████████████████████████████████████████████
▄▄▄ ███▄ █ ███▄ █ ██░ ██ ▄▄▄ ▄▄▄ ▄▄▄█████▓
▒████▄ ██ ▀█ █ ██ ▀█ █ ▒▓██░ ██ ▒████▄ ▒████▄ ▓ ██▒ ▓▒
▒██ ▀█▄ ▓██ ▀█ ██▒▓██ ▀█ ██▒░▒██▀▀██ ▒██ ▀█▄ ▒██ ▀█▄ ▒ ▓██░ ▒░
░██▄▄▄▄██▓██▒ ▐▌██▒▓██▒ ▐▌██▒ ░▓█ ░██ ░██▄▄▄▄██░██▄▄▄▄██░ ▓██▓ ░
▓█ ▓██▒██░ ▓██░▒██░ ▓██░ ░▓█▒░██▓ ▓█ ▓██ ▓█ ▓██ ▒██▒ ░
▒▒ ▓▒█░ ▒░ ▒ ▒ ░ ▒░ ▒ ▒ ▒ ░░▒░▒ ▒▒ ▓▒█ ▒▒ ▓▒█ ▒ ░░
░ ▒▒ ░ ░░ ░ ▒░░ ░░ ░ ▒░ ▒ ░▒░ ░ ░ ▒▒ ░ ▒▒ ░
░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ░ ▒ ░ ▒ ░ ░
░ ░ ░ ░ ░ ░ ░ ░
*/
//#include <bits/BaoMinhTranc++.h>
#include <bits/stdc++.h>
#define int int64_t
//#define ll int64_t
#define ld long double
#define ii pair<int,int>
#define iii pair<int,ii>
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define ALLr(x) x.rbegin(),x.rend()
#define upgrade ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define name "youreagoodmanarthur"
using namespace std;
const int Max=1<<20;
const int N=1e5+3;
const int INF=1e18;
const int MOD=998244353;
const int MOD2=1e9+8;
const int base=26;
const int LOG=32;
template<class X,class Y>
bool minimize(X& x,const Y& y)
{
if(x>y){
x=y;
return 1;
}return 0;
}
template<class X,class Y>
bool maximize(X& x,const Y& y)
{
if(x<y){
x=y;
return 1;
}return 0;
}
int s,n;
int dp[N];
void solve()
{
cin>>s>>n;
for(int _=1;_<=n;_++){
int v,w,k;cin>>v>>w>>k;
int bit;
for(int i=LOG;i>=0;i--)if(k>>i&1){
bit=i;break;
}
for(int i=0;i<bit;i++){
int tp=1<<i;
for(int j=s;j>=w*tp;j--)maximize(dp[j],dp[j-w*tp]+v*tp);
}
int tp=k-(1<<bit)+1;
for(int j=s;j>=w*tp;j--)maximize(dp[j],dp[j-w*tp]+v*tp);
}
cout<<*max_element(dp+1,dp+s+1);
}
void prepare()
{
}
signed main()
{
upgrade
if(fopen(name".INP","r")){
freopen(name".INP","r",stdin);
freopen(name".OUT","w",stdout);
}
prepare();
int test=1;
// cin>>test;
while(test--)solve();
return 0;
}
/*
░▓▓
░▒▒▒ ░▒▒▒▒▒▒░░░ ░▓▓
▓▒ ▒▓▓▓▓▓▓▓▓▓▓▓▓▒ ░▓▓▓▓▓▓▓▓▓▓▓▒░ ▒▓▓▒ ▒▒▒▒░ ░░░░▒░▒▒▒▒▒▒ ░▓▓ ░░▒▒▒▒▒░░
▒▓▓▒ ▒▓▓░ ░▓▓▒ ░▓▓▓▒ ░▒▓▓░░▓▓▒ ▒▒▒ ▒▒▒▒▒▒░░░▒▒▒▒▒▒▒▒▒▒▒░ ░▓▓▓▒▒▒▒▒▒▒▒▒▒▓▒▒░
▓▓▓▓▒ ░▓▓▒ ▒▓▓▒ ░▓▓▓░ ░▒░ ░▒▒▒▒▒▒▒▒ ▒▒▒░ ▒▒▒ ░▓▓
░▓▓░ ▓▓▓ ░▒▒▒ ▒▒▒ ░▒▒ ▒▓▒
▒▓▒ ▓▓▓ ░░ ▒▒░ ▒▒▒ ▒▒░ ▓▓▓
░▓▒ ░▓▓▓ ░▒ ▒▒░ ▒▒░ ▒▒░ ▒▒▒ ▓▓▓░
░▓▒ ░▓▓▓▒ ▒▒▒ ░▒▒▒░ ░▒▒░ ░▒▒ ▒▒▒ ▓▓▓▒
▒▓▒ ▓▓▓░ ░ ▒▒░ ▒▒▒ ▒▒▒▒▒▒▒▒░ ▒▒▒▒▒▒▒▒ ░▓▓▓
░▓▓▒ ▒▓▓▓▒ ░▓▓▓▓▒ ░▒▒ ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▒▒▒░ ░▓▓▓
░▒ ░▓▓▓▓▓▓▒░ ▒▓▓▓▓▓▒▓▓▒ ▒▒▒▒▒▒▒░ ░▒▒▒▒▒▒▒░ ▓▓▓▓▒▒ ▒▓▓▓▓
░░▓▓▓▓▓▓▓▓▒░░ ▒▓▒ ░▒▒▒▒░ ░▒▓▓▓▓▓▓▓▓▒░
▒▓▓░ ▒▒░
▓▒ ▒▓▓░ ▒▒▒░
▓▓▒ ░▓▓▒ ░▒▒▒▒
▓▓▓░ ▒▓▓▓ ░▒▒▒
░▓▓▓▓░ ░▓▓▓▒
░▓▓▓▓▓▒▒░░░ ░░░▒▒▓▓▓▓░
░▒▒▒▒▒▒▒▒░
*/
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
