Http://acm.hdu.edu.cn/showproblem.php?
pid=1257
Main topic:
There is a missile interception system that can only emit shells that are lower than the previous one at a time, given the attack order of some missiles, asking for at least how many missile interceptors are needed to completely stop
Ideas:
Long time no problem. To do the water ~
Direct simulation is possible ~
#include <cstdio>const int maxn = 30000 + 10;const int INF = 0x3ffffff;int A[MAXN], ans;int CUR_MAX[MAXN]; The maximum height the current missile system can reach is int main () {int n;while (~scanf ("%d", &n)) {for (int i = 0; i < n; i++) scanf ("%d", &a[i]); ans = 1 ; Cur_max[0] = a[0];for (int i = 1; i < n; i++) {int dis_min = inf;for (int j = 0; J < ans; J + +) {//When the current missile is smaller than a missile system capable of interception Wait//Find the closest to this missile height if (A[i] < cur_max[j] && dis_min > cur_max[j]) dis_min = j;} if (dis_min = = INF) Dis_min = ans++;cur_max[dis_min] = A[i];} printf ("%d\n", ans);} return 0;}
HDU 1257 Minimum interception system