Luo Gu P2722 Total Score Inflation
https://www.luogu.org/problem/P2722
JDOJ 1697: Score Inflation
https://neooj.com/oldoj/problem.php?id=1697
Description
The more students score in our Chittagong High School (USACO) competition in the happier we are. We try to design our contests so that people can score as many points as possible, we need your help. We can choose from several competition categories the problem, here's a "species" refers to a collection of a contest topic, to solve a set of topics that require the same amount of time and energy to get the same score.
your task is to write a program to tell USACO staff, it should be from each how many questions to select a category, so that the total time-consuming to solve the problem of competition in the prescribed time and score maximum.
inputs include race against time, M (1 <= M < = 10,000) ( Do not worry, you go to training camp there will in the long match) and N, the number of "type" of 1 <= N <= 10,000.
each line comprises two integers later to describe a "genre":
the first integer instructions to address this topic You can get scores (1 <= points <= 10000 ), the second integer instructions for resolving the time required for this topic (1 <= minutes <= 10000 ).
your program should determine we should be selected from each "kind" how much time can make road title in the competition The maximum score obtained.
The maximum number of points from any of the subject "genre" may be any non-negative number (0 or more). The resulting calculated possible.
Input
Line 1: M, the number of "type" of the time and subject N-- race.
Of 2-N + 1 rows: two integers: Processed fractions and each "type" topic.
Output
A single line that includes the biggest score in a given limit may get.
Sample Input
Sample Output
HINT
From 4 "species" selected the first two "species" selected two title three questions
#include<cstdio> #include<algorithm> using namespace std; int n,m; int a[10001],b[10001],dp[10001]; int main() { scanf("%d%d",&m,&n); for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]); for(int i=1;i<=n;i++) for(int j=b[i];j<=m;j++) dp[j]=max(dp[j],dp[j-b[i]]+a[i]); printf("%d",dp[m]); return 0; }