⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3341557_ac_63ms_276k.cpp

📁 北大大牛代码 1240道题的原代码 超级权威
💻 CPP
字号:
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

vector <int> array;
vector <int> ans;

int main()
{
	int n, i, t, tmp, max, j, cas;

	cas = 1;
	while (scanf("%d",&t)==1)
	{
		if (t==-1)
		{
			break;
		}
		array.clear();
		array.push_back(t);
		while (scanf("%d",&t)==1&&t!=-1)
		{
			array.push_back(t);
		}
		ans.clear();
		n = array.size();
		max = 0;
		for (i = 0; i < n; i++)
		{
			tmp = 1;
			for (j = 0; j < i; j++)
			{
				if (array[j]>=array[i]&&ans[j]+1>tmp)
				{
					tmp = ans[j]+1;
				}
			}
			ans.push_back(tmp);
			if (tmp > max)
			{
				max = tmp;
			}
		}
		printf("Test #%d:\n  maximum possible interceptions: %d\n\n",cas++,max);
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -