Submission #344746

#TimeUsernameProblemLanguageResultExecution timeMemory
344746tata666Bigger segments (IZhO19_segments)C++17
37 / 100
1588 ms2668 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define sz(x) (int)x.size() #define sbb (x & (-x)) #define all(x) begin(x), end(x) using namespace std; typedef long long llong; typedef pair <llong, int> pii; const int MXN = 4e5 + 7; const int MOD = 1e9 + 7; const llong INF = 1e18 + 7; const int N = 2e5; int n, a[MXN], dp[MXN]; llong pref[MXN], mx[MXN]; int main(){ ios_base::sync_with_stdio(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; pref[i] = pref[i - 1] + a[i]; } dp[1] = 1; for(int i = 1; i <= n; i++){ int k = i; for(; k >= 1; k--){ if(pref[i] - pref[k - 1] >= mx[k - 1]) break; } dp[i] = dp[k - 1] + 1; mx[i] = pref[i] - pref[k - 1]; } cout << dp[n]; 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...