Pre-exam review (Codevs 2837)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.