제출 #344758

#제출 시각아이디문제언어결과실행 시간메모리
344758tata666Bigger segments (IZhO19_segments)C++17
13 / 100
775 ms262148 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second using namespace std; typedef long long llong; const int MOD = 1e9 + 7; const int MXN = 4e5 + 7; const llong INF = 1e18 + 7; int n, dp[3011][3011], ans; llong a[3011], pref[3011]; vector <int> pos[3011]; int main(){ ios_base::sync_with_stdio(0); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; pref[i] = pref[i - 1] + a[i]; dp[1][i] = 1; pos[i].pb(1); } for(int i = 1; i <= n; i++){ for(int j : pos[i]){ for(int k = 1; k <= n; k++){ if(pref[i] - pref[j - 1] <= pref[k] - pref[i]){ dp[i + 1][k] = max(dp[i + 1][k], dp[j][i] + 1); if(k < n) pos[k].pb(i + 1); } } } pos[i].clear(); } for(int i = 1; i <= n; i++){ ans = max(ans, dp[i][n]); } cout << ans; return 0; }
#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...