Submission #299746

#TimeUsernameProblemLanguageResultExecution timeMemory
299746dantoh000Bigger segments (IZhO19_segments)C++14
37 / 100
1538 ms1592 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; typedef long long ll; typedef pair<int,int> ii; typedef pair<ll, int> li; ii dp[500005]; int n; ll p[500005]; int main(){ scanf("%d",&n); for (int i = 1; i <= n; i++){ scanf("%lld",&p[i]); p[i]+=p[i-1]; dp[i] = {0,0}; for (int j = i-1; j >= 0; j--){ if (p[i]-p[j] >= p[j]-p[dp[j].se]){ dp[i] = max(dp[i],{dp[j].fi+1, j}); break; } } } printf("%d",dp[n].fi); }

Compilation message (stderr)

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