Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
91150 sh25_shenpy 神父过河 C++ 解答错误 0 MS 248 KB 618 2026-06-12 15:10:21

Tests(0/19):


#include <bits/stdc++.h> using namespace std; int n,mx; struct node{ int st,en,sum; }dp[100010]; bool cmp(node a,node b){ return a.st<b.st; } int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>dp[i].st>>dp[i].en; dp[i].sum=1; } sort(dp+1,dp+n+1,cmp);//排好河左岸的位置 for(int j=1;j<=n;j++){ for(int i=1;i<j;i++){ if(dp[i].en<dp[j].en){ dp[j].sum=max(dp[j].sum,dp[i].sum+1); mx=max(dp[j].sum,mx);//求河右岸的最长上升子序列 } } } cout<<mx; return 0; }


测评信息: