Submission #526376

#TimeUsernameProblemLanguageResultExecution timeMemory
526376Bill_00Bigger segments (IZhO19_segments)C++14
37 / 100
1581 ms3308 KiB
#include <bits/stdc++.h> #define MOD 1000000007 #define ff first #define ss second #define N 500005 typedef long long ll; const ll mx = 1e9 + 100005; using namespace std; ll a[N], M[N], H[N], sum[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; sum[i] = sum[i - 1] + a[i]; } for(int i = 1; i <= n; i++){ for(int j = i - 1; j >= 0; j--){ if(sum[i] - sum[j] >= M[j]){ M[i] = sum[i] - sum[j]; H[i] = H[j] + 1; break; } } } cout << H[n]; }
#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...