제출 #497344

#제출 시각아이디문제언어결과실행 시간메모리
497344IerusBigger segments (IZhO19_segments)C++17
0 / 100
1 ms332 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize ("unroll-loops,Ofast,O3") #pragma GCC target("avx,avx2,fma") #define F first #define S second #define int long long #define sz(x) (int)x.size() #define pb push_back #define eb emplace_back #define all(x) (x).begin(),(x).end() const int E = 5e5+777; const long long inf = 1e18+777; const int N = 3e3+777; const int MOD = 1e9+7; int n, a[E], pref[E], dp[N][N]; int get(int l, int r){ return pref[r] - pref[l-1]; } signed main(){ ios_base::sync_with_stdio(0), cin.tie(0),cout.tie(0); cin >> n; for(int i = 1; i <= n; ++i){ cin >> a[i]; pref[i] = pref[i-1] + a[i]; } for(int len = 1; len <= n; ++len){ for(int l = 1, r = len; r <= n; ++r, ++l){ if(l == 1 && r == 1){ dp[l][r] = 1; continue; } for(int l1 = 0; l1 < l; ++l1){ for(int r1 = l1; r1 < l; ++r1){ if(get(l1, r1) <= get(l, r)){ dp[l][r] = max(dp[l][r], dp[l1][r1]); } } } if(dp[l][r]) ++dp[l][r]; } } // for(int i = 1; i <= n; ++i){ // for(int j = i; j <= n; ++j){ // cout << "{" << i << "," << j << "}: " << dp[i][j] << '\n'; // } // } int res = 0; for(int i = 1; i <= n; ++i){ res = max(res, dp[i][n]); } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...