Submission #341146

#TimeUsernameProblemLanguageResultExecution timeMemory
341146beksultan04K blocks (IZhO14_blocks)C++14
32 / 100
1086 ms492 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define OK puts("OK"); #define NO puts("NO"); #define YES puts("YES"); #define fr first #define sc second #define ret return #define scanl(a) scanf("%lld",&a); #define scanll(a,b) scanf("%lld %lld",&a, &b); #define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define scan1(a) scanf("%d",&a); #define scan2(a,b) scanf("%d %d",&a, &b); #define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c); #define all(s) s.begin(),s.end() #define allr(s) s.rbegin(),s.rend() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); #define eps 1e-12 const int N = 1e5+12; const ll INF=1e15+7; int q[N],n; bool vis[N][101]; ll dp[N][101]; ll rec(int i,int k,ll sum){ if (i == n && k == 0)ret sum; if (k == 0 || k != 0 && i == n)ret INF; int mx=0,j; ll ans=INF; for (j=i+1;j<=n;++j){ mx = max(mx,q[j]); ans = min(ans,rec(j,k-1,sum+mx)); } ret dp[i][k] = ans; } main(){ int i,k; scan2(n,k) for (i=1;i<=n;++i){ scan1(q[i]) } cout <<rec(0,k,0); }

Compilation message (stderr)

blocks.cpp: In function 'long long int rec(int, int, long long int)':
blocks.cpp:31:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   31 |     if (k == 0 || k != 0 && i == n)ret INF;
      |                   ~~~~~~~^~~~~~~~~
blocks.cpp: At global scope:
blocks.cpp:41:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main(){
      |      ^
blocks.cpp: In function 'int main()':
blocks.cpp:15:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 | #define scan2(a,b) scanf("%d %d",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~
blocks.cpp:43:5: note: in expansion of macro 'scan2'
   43 |     scan2(n,k)
      |     ^~~~~
blocks.cpp:14:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 | #define scan1(a) scanf("%d",&a);
      |                  ~~~~~^~~~~~~~~
blocks.cpp:45:9: note: in expansion of macro 'scan1'
   45 |         scan1(q[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...