为什么用动态数组和lower_bound超时?
查看原帖
为什么用动态数组和lower_bound超时?
910992
hupan8845074楼主2024/8/24 21:34
#include<bits/stdc++.h>
#define ll long long
const int N=1e6;
using namespace std;
ll n,m,k,a[N],b[N];
vector<ll> c;
int main(){
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		for(int j=1;j<=n;j++){
			c.insert(lower_bound(c.begin(),c.end(),a[j]+b[i]),a[j]+b[i]);
		}
	}
	cout<<c[k-1];
	return 0;
}
2024/8/24 21:34
加载中...