Submission #336437

#TimeUsernameProblemLanguageResultExecution timeMemory
336437beksultan04Bigger segments (IZhO19_segments)C++14
37 / 100
1593 ms1792 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); const int N = 5e5+12,INF=1e9+7; int q[N],p[N],dp[N]; main(){ int n,m,i,j; scan1(n) for (i=1;i<=n;++i){ int x,tmp=0; scan1(x) p[i]=p[i-1]+x; for (j=i-1;j>=0;--j){ if (q[j] <= p[i] && dp[j] >= dp[i]){ tmp = j; break; } } dp[i] = dp[tmp]+1; q[i] = 2*p[i]-p[tmp]; } cout <<dp[n]; }

Compilation message (stderr)

segments.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main(){
      |      ^
segments.cpp: In function 'int main()':
segments.cpp:19:11: warning: unused variable 'm' [-Wunused-variable]
   19 |     int n,m,i,j;
      |           ^
segments.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
segments.cpp:20:5: note: in expansion of macro 'scan1'
   20 |     scan1(n)
      |     ^~~~~
segments.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
segments.cpp:23:9: note: in expansion of macro 'scan1'
   23 |         scan1(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...