// Problem: 非零段划分 // Contest: AcWing // URL: https://www.acwing.com/problem/content/4010/ // Memory Limit: 512 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h> using namespace std; #define ll long long //# define int long long #define ull unsigned long long #define pii pair<int,int> //#define double in #define baoliu(x, y) cout << fixed << setprecision(y) << x #define endl "\n"
const int N = 5e5 + 10; const int M = 1e6 + 10; const int inf = 0x3f3f3f3f; const int mod = 998244353; const double eps = 1e-8; int n, m; int a[N];int cnt[10010]; void solve(){ cin>>n; bool flag=false; for(int i=1;i<=n;i++){ cin>>a[i]; if(a[i]>0)flag=true; } if(!flag){ cout<<0<<endl; return ; } else { int mx=-1; for(int i=1;i<=n;i++){ if(a[i]>a[i-1]){ //本质上是给这个区间加1,然后考虑差分降低时间复杂度 //加1的含义是p在这个区间的时候,非零子段数量加1 cnt[a[i-1]+1]++; cnt[a[i]+1]--; } } int s=0; for(int i=1;i<=10000;i++){ s+=cnt[i]; mx=max(s,mx); } cout<<mx<<endl; } } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);