Submission #299745

#TimeUsernameProblemLanguageResultExecution timeMemory
299745dantoh000Bigger segments (IZhO19_segments)C++14
0 / 100
1 ms512 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]; priority_queue<li ,vector<li>, greater<li> > pq; int main(){ scanf("%d",&n); pq.push({0,0}); for (int i = 1; i <= n; i++){ scanf("%lld",&p[i]); p[i]+=p[i-1]; for (int j = i-1; j >= 0; j--){ if (p[i]-p[j] >= p[j]-p[dp[j].se]){ dp[i].fi = dp[pq.top().se].fi + 1; dp[i].se = pq.top().se; break; } } } printf("%d",dp[n].fi); }

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("%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...