제출 #1307181

#제출 시각아이디문제언어결과실행 시간메모리
1307181jahongirBigger segments (IZhO19_segments)C++20
27 / 100
1523 ms27852 KiB
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define pb push_back #define all(a) a.begin(),a.end() typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef unsigned long long ull; typedef vector<int> vi; const int mxn = 2e5+1; ll pref[mxn]; int dp[3001][3001]; void solve(){ int n; cin >> n; assert(n <= 3000); for(int i = 1; i <= n; i++){ cin >> pref[i]; pref[i] += pref[i-1]; } for(int i = 1; i <= n; i++){ dp[i][0] = 1; for(int j = 1; j < i; j++){ dp[i][j] = -1e9; for(int k = j-1; k >= 0; k--){ if(pref[i]-pref[j]<pref[j]-pref[k]) break; dp[i][j] = max(dp[i][j],dp[j][k]+1); } } } cout << *max_element(dp[n],dp[n]+n); } signed main(){ cin.tie(0)->sync_with_stdio(0); int t = 1; // cin >> t; while(t--){solve();} }
#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...