Submission #257540

#TimeUsernameProblemLanguageResultExecution timeMemory
257540BTheroBigger segments (IZhO19_segments)C++17
37 / 100
13 ms640 KiB
// chrono::system_clock::now().time_since_epoch().count() #include<bits/stdc++.h> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MAXN = (int)3e3 + 5; const ll INF = (ll)1e16; pair<int, ll> dp[MAXN]; int arr[MAXN]; int n; void solve() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &arr[i]); } for (int i = 1; i <= n; ++i) { dp[i] = mp(0, INF); } dp[0] = mp(0, 0); for (int i = 1; i <= n; ++i) { ll cur = 0; for (int j = i; j; --j) { cur += arr[j]; if (dp[j - 1].se <= cur) { dp[i] = max(dp[i], mp(dp[j - 1].fi + 1, -cur)); } } dp[i].se *= -1; } printf("%d\n", dp[n].fi); } int main() { int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

segments.cpp: In function 'void solve()':
segments.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
segments.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &arr[i]);
     ~~~~~^~~~~~~~~~~~~~~
#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...