Submission #344553

#TimeUsernameProblemLanguageResultExecution timeMemory
344553tata666Bigger segments (IZhO19_segments)C++17
0 / 100
1 ms492 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, ans; int dp[3001][3001]; llong pref[MXN], a[MXN]; 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]; dp[1][i] = 1; pref[i] = pref[i - 1] + a[i]; } for(int i = 1; i <= n; i++){ for(int j = i; j <= n; j++){ for(int k = j + 1; k <= n; k++){ if(pref[j] - pref[i - 1] <= pref[k] - pref[j]){ dp[j + 1][k] = max(dp[j + 1][k], dp[i][j] + 1); } } } } for(int i = 1; i <= n; i++){ ans = max(dp[i][n], ans); } 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...