社区讨论

为什么被hack

P1020[NOIP 1999 提高组] 导弹拦截参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@mdyabham
此快照首次捕获于
2025/08/05 16:36
7 个月前
此快照最后确认于
2025/11/04 03:09
4 个月前
查看原帖
CPP
#include <bits/stdc++.h>
using namespace std;
string str;
int x,ans,ans2;
vector<int> v;
void f1()
{
	vector<int> ve;
	for(int i:v)
	{
		auto it=upper_bound(ve.begin(),ve.end(),i,greater<int>());
		if(it==ve.end())
			ve.push_back(i);
		else
			*it=i;
	}
	ans=ve.size();
}
void f2()
{
	vector<int> ve;
	for(int i:v)
	{
		auto it=lower_bound(ve.begin(),ve.end(),i);
		if(it==ve.end())
			ve.push_back(i);
		else
			*it=i;
	}
	ans2=ve.size();
}
int main()
{
	ios::sync_with_stdio(0);
	cout.tie(0);cin.tie(0);
	getline(cin,str);
	for(int i=0;i<str.size();i++)
		if(str[i]==' ')
			v.push_back(x),x=0;
		else
			x=x*10+(str[i]-'0');
	v.push_back(x);
	f1();
	cout<<ans<<"\n";
	f2(); 
	cout<<ans2;
	return 0;
}
//lower_bound 

回复

0 条回复,欢迎继续交流。

正在加载回复...