Submission #344578

#TimeUsernameProblemLanguageResultExecution timeMemory
344578NurlykhanBigger segments (IZhO19_segments)C++17
13 / 100
2 ms364 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = (int)300 + 10; const int mod = (int)1e9 + 7; int n; int a[N]; ll pref[N]; ll get_sum(int l, int r) { return pref[r + 1] - pref[l]; } int dp[N][N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); pref[i] = pref[i - 1] + a[i]; } for (int r0 = 0; r0 <= n; r0++) { for (int r1 = r0 + 1; r1 <= n; r1++) { dp[r0][r1] = -mod; } dp[0][r0] = 0; } for (int r0 = 0; r0 <= n; r0++) { for (int r1 = r0 + 1; r1 <= n; r1++) { for (int r2 = r1 + 1; r2 <= n; r2++) { if (2 * pref[r1] - pref[r0] <= pref[r2]) { dp[r1][r2] = max(dp[r1][r2], dp[r0][r1] + 1); } } } } int ans = 0; for (int r0 = 0; r0 <= n; r0++) ans = max(ans, dp[r0][n]); cout << ans + 1; return 0; }

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
segments.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |         scanf("%d", &a[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...