Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1257
The DP array records the height at which a set of interception systems can now be intercepted.
Greed can be over, each read into a missile height, and before the lowest comparison, if the missile is higher than before, it is necessary to add a set of interception system, and the height of the missile is recorded. If it is lower than the previous one, then let the most recent set of interception systems higher than it intercept it, and change that set of DP values.
1#include <cstdio>2#include <cstdlib>3#include <cstring>4#include <algorithm>5#include <iostream>6#include <cmath>7#include <queue>8#include <map>9#include <Set>Ten#include <stack> One#include <list> A#include <vector> - - using namespacestd; the - Const intMAXN =30010; - intN; - inttmp; + intDP[MAXN]; - + intMain () { A //freopen ("in", "R", stdin); at while(~SCANF ("%d", &N)) { - intCNT =1; - intFlag =0; - while(n--) { -scanf"%d", &tmp); - if(!flag) { indp[0] =tmp; -Flag =1; to } + inti; - for(i =0; I < CNT; i++) { the if(TMP <=Dp[i]) { *Dp[i] =tmp; $ Break;Panax Notoginseng } - } the if(i = =CNT) { +dp[cnt++] =tmp; A } the } +printf"%d\n", CNT); - } $}
[HDOJ1261] Minimum interception system