Submission #997826

#TimeUsernameProblemLanguageResultExecution timeMemory
997826daffuwuBigger segments (IZhO19_segments)C++14
100 / 100
65 ms13136 KiB
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int dp[500069], n, a, mx, p[500069]; long long ps[500069]; int main() { int i, j; scanf("%d", &n); for (i=1; i<=n; i++) { scanf("%d", &a); ps[i] = ps[i-1]+a; } for (i=1; i<=n; i++) { p[i] = max(p[i-1], p[i]); dp[i] = dp[p[i]]+1; j = lower_bound(ps+1, ps+n+1, 2*ps[i]-ps[p[i]])-ps; p[j] = i; } printf("%d\n", dp[n]); }

Compilation message (stderr)

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