2837 Review before the exam
time limit: 1 sspace limit: 128000 KBtitle level: Golden Gold SolvingView Run ResultsTitle Description
Description
Aiden to take the exam immediately, but he did not review how, so he decided to cram. He lists n points of knowledge and analyzes the time t required to review each knowledge point and the possible score K. He now has a T-time to review, and he wants to pick the right knowledge points to get the highest desired score in the shortest possible time.
Enter a description
Input Description
The first line, two numbers, is N, T.
The next n rows, two numbers per line, T, K, indicate the time and desired score for a knowledge point.
Output description
Output Description
A row, a number, that represents the highest desired score that can be obtained.
Sample input
Sample Input
3 5
3 5
3 2
2 2
Sample output
Sample Output
7
#include <cstdio>#include<iostream>#defineM 10010#defineN 5010using namespacestd;intF[m],v[n],w[n];intMain () {intM,n; scanf ("%d%d",&n,&m); for(intI=1; i<=n;i++) scanf ("%d%d",&w[i],&V[i]); for(intI=1; i<=n;i++) for(intj=m;j>=w[i];j--) F[j]=max (f[j],f[j-w[i]]+V[i]); printf ("%d", F[m]); return 0;}
View Code
Pre-exam review (Codevs 2837)