Submission #1077775

#TimeUsernameProblemLanguageResultExecution timeMemory
1077775ntdaccodeK blocks (IZhO14_blocks)C++17
53 / 100
1076 ms9072 KiB
#include<bits/stdc++.h> #define fori(i,a,b) for(int i=a;i<=b;i++) #define int long long #define ii pair<int,int> #define fi first #define se second #define pb push_back using namespace std; const int mod=1e9+7; const int M=1e4+10; const int N=1e3+10; int n,k,a[M],f[M][110]; int kq=0; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "1" if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin >> n >> k; fori(i,1,n) cin >> a[i]; memset(f,61,sizeof(f)); f[0][0]=0; fori(j,1,k) { fori(i,1,n) { int ma=0; for(int pos=i;pos!=0;pos--) { ma=max(ma,a[pos]); f[i][j]=min(f[i][j],f[pos-1][j-1]+ma); } } } cout << f[n][k] ; }

Compilation message (stderr)

blocks.cpp: In function 'int32_t main()':
blocks.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
blocks.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen(task".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...