HDU 1257 minimum Interception System
Question:
There is a missile interception system that can only launch shells lower than the previous one at a time. Given the attack sequence of some missiles, the minimum number of missile interception systems required to completely block them
Ideas:
I haven't done any questions for a long time. Questions ~
Directly simulate it ~
# Include
Const int MAXN = 30000 + 10; const int INF = 0x3ffffff; int a [MAXN], ans; int cur_max [MAXN]; // 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 that can be intercepted, // find the 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, ans );} return 0 ;}