社区讨论
95分1TLE求调
P1893[USACO10OPEN] 山峰暸望 Mountain Watching S参与者 3已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @mhj9xc4k
- 此快照首次捕获于
- 2025/11/03 23:07 4 个月前
- 此快照最后确认于
- 2025/11/03 23:07 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
int n,h[10010],mx=1;
int main(){
std::ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++) cin>>h[i];
for(int i=1;i<n;i++){
for(int j=i+1;j<=n;j++){
int ss=0,xj=0,s1=0,x1=0;
for(int k=i;k<=j;k++){
if(ss<=h[k]&&xj==0){
ss=h[k];
s1++;
}
else{
if(xj==0) xj=h[k];
if(xj>=h[k]){
xj=h[k];
x1++;
}
else break;
}
}
mx=max(mx,s1+x1);
}
}
cout<<mx;
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...