其他分享
首页 > 其他分享> > 2945:拦截导弹

2945:拦截导弹

作者:互联网

2945:拦截导弹

动态规划
题目链接


#include<iostream>
#include<algorithm>
using namespace std;
int a[30], b[30] = { 0 };
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int maxx = 0;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (a[i] <= a[j]) {
				b[i] = max(b[i], b[j] + 1);
				maxx = max(maxx, b[i]);
			}
		}
	}
	cout << maxx+1;
	return 0;
}

标签:拦截导弹,maxx,int,max,30,++,2945,include
来源: https://blog.csdn.net/weixin_46028214/article/details/112912854