BZOJ 1606 Usaco Hay for Sale

裸的背包=。= 没什么思维难度的题目.

 1 #include <cstdio>
 2  
 3 bool dp[100005];
 4 int n,V,x;
 5  
 6 int main(){
 7     scanf("%d%d",&V,&n);
 8     dp[0]=1;
 9     for(int i=1;i<=n;i++){
10         scanf("%d",&x);
11         for(int j=V;j>=x;j--){
12             dp[j] = dp[j-x]+1;
13         }
14     }
15     for(int i=V;i>=0;i--){
16         if(dp[i]){
17             printf("%d\n",i);
18             break;
19         }
20     }
21     return 0;
22 }
时间: 2024-10-11 10:40:35

BZOJ 1606 Usaco Hay for Sale的相关文章

【bzoj 1606】 [Usaco2008 Dec]Hay For Sale 购买干草 01背包

1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 978 Solved: 735 [Submit][Status][Discuss] Description 约翰遭受了重大的损失:蟑螂吃掉了他所有的干草,留下一群饥饿的牛.他乘着容量为C(1≤C≤50000)个单位的马车,去顿因家买一些干草. 顿因有H(1≤H≤5000)包干草,每一包都有它的体积Vi(l≤Vi≤C).约翰只能整

[bzoj 1606] [Usaco2008 Dec]Hay For Sale 购买干草 (dp)

1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1307  Solved: 964[Submit][Status][Discuss] Description 约翰遭受了重大的损失:蟑螂吃掉了他所有的干草,留下一群饥饿的牛.他乘着容量为C(1≤C≤50000)个单位的马车,去顿因家买一些干草.  顿因有H(1≤H≤5000)包干草,每一包都有它的体积Vi(l≤Vi≤C).约翰只

bzo1606: [Usaco2008 Dec]Hay For Sale 购买干草

1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1338  Solved: 991[Submit][Status][Discuss] Description 约翰遭受了重大的损失:蟑螂吃掉了他所有的干草,留下一群饥饿的牛.他乘着容量为C(1≤C≤50000)个单位的马车,去顿因家买一些干草.  顿因有H(1≤H≤5000)包干草,每一包都有它的体积Vi(l≤Vi≤C).约翰只

BZOJ1606: [Usaco2008 Dec]Hay For Sale 购买干草

1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 612  Solved: 463[Submit][Status] Description 约翰遭受了重大的损失:蟑螂吃掉了他所有的干草,留下一群饥饿的牛.他乘着容量为C(1≤C≤50000)个单位的马车,去顿因家买一些干草.  顿因有H(1≤H≤5000)包干草,每一包都有它的体积Vi(l≤Vi≤C).约翰只能整包购买, 他最多

[BZOJ 1652][USACO 06FEB]Treats for the Cows 题解(区间DP)

[BZOJ 1652][USACO 06FEB]Treats for the Cows Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given

BZOJ 1606 Hay For Sale 购买干草

#include<iostream>#include<cstdio>#include<cstring>using namespace std;int v,n,r[5050],dp[50050];int main(){ scanf("%d%d",&v,&n); for (int i=1;i<=n;i++) scanf("%d",&r[i]); for (int i=1;i<=n;i++) for

AC日记——[USACO08DEC]干草出售Hay For Sale 洛谷 P2925

题目描述 Farmer John suffered a terrible loss when giant Australian cockroaches ate the entirety of his hay inventory, leaving him with nothing to feed the cows. He hitched up his wagon with capacity C (1 <= C <= 50,000) cubic units and sauntered over t

洛谷P2925 [USACO08DEC]干草出售Hay For Sale

题目描述 Farmer John suffered a terrible loss when giant Australian cockroaches ate the entirety of his hay inventory, leaving him with nothing to feed the cows. He hitched up his wagon with capacity C (1 <= C <= 50,000) cubic units and sauntered over t

洛谷——P2925 [USACO08DEC]干草出售Hay For Sale

https://www.luogu.org/problem/show?pid=2925 题目描述 Farmer John suffered a terrible loss when giant Australian cockroaches ate the entirety of his hay inventory, leaving him with nothing to feed the cows. He hitched up his wagon with capacity C (1 <= C