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)