mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
parent
8ede099d14
commit
64ac2ad5a7
19
VIJOS/1317_hzwer.cpp
Normal file
19
VIJOS/1317_hzwer.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int m,n,i,v;
|
||||
int w[25],c[25],f[30001];
|
||||
cin>>m>>n;
|
||||
for(i=1;i<=n;i++)
|
||||
{
|
||||
cin>>w[i]>>c[i];
|
||||
c[i]*=w[i];
|
||||
}
|
||||
for(i=1;i<=n;i++)
|
||||
for(v=m;v>=w[i];v--)
|
||||
if(f[v]<f[v-w[i]]+c[i])
|
||||
f[v]=f[v-w[i]]+c[i];
|
||||
cout<<f[m];
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user