计蒜客 防御导弹

天大地大妈咪最大 提交于 2019-11-30 01:11:44
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>

#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define l(x) (x<<1)
#define r(x) (x<<1|1)
#define ms(a,b) memset(a,b,sizeof(a))

using namespace std;

int n, demo[2222];
int dp[2222],temp;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &demo[i]);
	ms(dp, INF);

	for (int i = 0; i < n; i++) {
		temp = i;
		for (int j = 0; j < i; j++) 
			if (demo[i] <= dp[j] && dp[j] < dp[temp]) 
				temp = j;
		if (temp == i)
			dp[i] = demo[i];
		else 
			dp[temp] = demo[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (dp[i] != INF) ans++;
	printf("%d\n", ans);

	return 0;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!