Ultraviolet A 12563-jin Ge Jin Qu Hao (Dynamic Planning ~ Jin! Song! Gold! Qu !)

Source: Internet
Author: User

I am speechless... Or the status is inaccurate ..

The transition equation of the initial state is very important, but it is not enough to simply introduce the equation.

Processing the boundary state and processing the Special State are all important. If a boundary state is wrong, it will lead to wa ....

Details! Clearer thinking and more comprehensive consideration!

# Include <cstdio> # include <cstring> # include <algorithm> using namespace STD; int N, T; int V [55]; int d [55] [10000]; int path [55] [10000]; int main () {int tt; scanf ("% d", & TT); For (INT Kase = 1; Kase <= tt; kase ++) {scanf ("% d", & N, & T); memset (path, 0, sizeof (PATH); memset (D, 0, sizeof (d); memset (v, 0, sizeof (v); For (INT I = 1; I <= N; I ++) {scanf ("% d", & V [I]) ;}for (INT I = N; I> = 1; I --) {for (Int J = 0; j <= T; j ++) {d [I] [J] = (I = N)? 0: d [I + 1] [J]; path [I] [J] = path [I + 1] [J]; If (j> = V [I]) {If (d [I] [J] <D [I + 1] [J-V [I] + 1) {path [I] [J] = V [I] + path [I + 1] [J-V [I]; d [I] [J] = d [I + 1] [J-V [I] + 1 ;} else if (d [I] [J] = d [I + 1] [J-V [I] + 1) path [I] [J] = max (path [I + 1] [J-V [I] + V [I], path [I + 1] [J]) ;}} int Max _ =-1; for (INT I = T-1; I> = 0; I --) {If (d [1] [I] = d [1] [T-1]) {If (max _ <path [1] [I]) max _ = path [1] [I];} printf ("case % d: % d \ n", Kase, d [1] [T-1] + 1, max _ + 678);} return 0 ;}


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.