Submission #1270907

#TimeUsernameProblemLanguageResultExecution timeMemory
1270907yeulerBigger segments (IZhO19_segments)C++20
13 / 100
1595 ms4168 KiB
#include <bits/stdc++.h> #define ll long long #define KAGAMINE ios_base::sync_with_stdio(false); #define LEN cin.tie(NULL); #define slv solve(); #define slve int tc = 1; cin >> tc; while(tc--){solve();} #define pls cout << "mantap\n"; #define fi first #define se second #define all(x) x.begin(), x.end() #define pb push_back #define vector2d(x) vector<vector<x>> #define pii pair<int, int> #define pl pair<ll, ll> const ll inf = 1e9+7; using namespace std; ll n; vector<ll> ar; vector<ll> wow(5e5+1, -1); ll solve(ll i, ll sum, ll bef){ if (i == n){ if (sum < bef) return -1; if (sum >= bef) return 0; } // if (wow[i] != -1) return wow[i]; wow[i] = solve(i+1, sum+ar[i], bef); if (sum < bef){ return wow[i]; } ll gk = solve(i+1, ar[i], sum); if (gk != -1){ wow[i] = max(wow[i], 1+gk); } return wow[i]; } int main(){ KAGAMINE LEN cin >> n; for (ll i = 0; i < n; i++){ ll tmp; cin >> tmp; ar.pb(tmp); } cout << solve(0, ar[0], 0); 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...