Submission #1135003

#TimeUsernameProblemLanguageResultExecution timeMemory
1135003poatBigger segments (IZhO19_segments)C++20
37 / 100
216 ms2784 KiB
// #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define int long long // #define mkp make_pair #define txt freopen("kout.in", "r", stdin), freopen("kout.out", "w", stdout); const int N = 200100, K = 20; const int mod = 1e9 + 7; void solve() { int n; cin >> n; int arr[n]; for(auto &i : arr) cin >> i; pair<int, int> dp[n + 5]; dp[0] = {1, arr[0]}; for(int i = 1; i < n; i++) { dp[i] = {dp[i - 1].first, dp[i - 1].second + arr[i]}; int s = arr[i], ind = 3000; for(int j = i - 1; j >= 0 && ind; j--) { ind--; if(s >= dp[j].second) { dp[i] = {dp[j].first + 1, s}; break; } s += arr[j]; } } cout << dp[n - 1].first << '\n'; } signed main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int T = 1; for (; 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...