Submission #1095419

#TimeUsernameProblemLanguageResultExecution timeMemory
1095419KerimBigger segments (IZhO19_segments)C++17
37 / 100
1594 ms2548 KiB
#include "bits/stdc++.h" #define ll long long using namespace std; const int N = 2e5+4; ll a[N], b[N], par[N]; int main(){ // freopen("file.in", "r", stdin); int n; scanf("%d", &n); for(int i = 1; i <= n; ++i){ int x; scanf("%d", &x); par[i] = par[i-1]+x; } a[1] = par[1]; b[1] = 1; for(int i = 1; i <= n; ++i) for(int j = i; j >= 1; --j) if(par[i]-par[j-1] >= a[j-1] and b[j-1]+1 > b[i]){ b[i] = b[j-1] + 1; a[i] = par[i]-par[j-1]; } printf("%lld\n", b[n]); return 0; }

Compilation message (stderr)

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