Poj 2392 space elevator (multiple backpacks)

Source: Internet
Author: User
Space Elevator
Time limit:1000 ms   Memory limit:65536 K
Total submissions:8110   Accepted:3843
Question: A group of cows need to use some stone heap towers to give the types of stones, the quantity of each type, the maximum height of the rock, and the number of each type of rock. template question .... Sort all the stones and drop the low-altitude face.
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> using namespace STD; struct class {int H, maxh, C;} A [405]; int CMP (Class X, class Y) {return X. maxh <Y. maxh;} int main () {int N, ANS, I, j, DP [40005], sum [40005]; while (CIN> N) {for (I = 0; I <n; I ++) CIN> A [I]. h> A [I]. maxh> A [I]. c; sort (A, A + N, CMP); memset (DP, 0, sizeof (DP); DP [0] = 1; int ans = 0; for (I = 0; I <n; I ++) {memset (sum, 0, sizeof (SUM); For (j = A [I]. h; j <= A [I]. maxh; j ++) {If (! DP [J] & DP [J-A [I]. h] & sum [J-A [I]. h] <A [I]. c) {DP [J] = 1; sum [J] = sum [J-A [I]. h] + 1; // count the number of stones placed. If (ANS <j) ans = J ;}}cout <ans <Endl ;}return 0 ;}


Poj 2392 space elevator (multiple backpacks)

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.