小心卡vector,这个只有70分,要不就是创空间被卡了,要么就是卡vector
查看原帖
小心卡vector,这个只有70分,要不就是创空间被卡了,要么就是卡vector
676619
finalSTian楼主2023/2/9 17:37
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
using namespace std;
#define rall(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define sz(a) (int) (a).size()
#define endl "\n"
void solved() {
int n,m;
cin>>n>>m;
vector<int> dp(m+1),t(m+1),x(m+1),y(m+1);
for(int i=1;i<=m;i++) cin>>t[i]>>x[i]>>y[i];
for(int i=1;i<=m;i++){
dp[i]=1;
	for(int j=1;j<i;j++){
	 int u=abs(x[i]-x[j])+abs(y[i]-y[j]);
	 if(u<=abs(t[j]-t[i])){
	 	dp[i]=max(dp[i],dp[j]+1);
	 }
	}
}
int ans=0;
for(int i=1;i<=m;i++) ans=max(ans,dp[i]);
cout<<ans<<endl;

}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
		solved();
	
	return 0;

}


2023/2/9 17:37
加载中...