Submission #443855

#TimeUsernameProblemLanguageResultExecution timeMemory
443855NintsiChkhaidzeK blocks (IZhO14_blocks)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #define pb push_back #define s second #define f first #define ll long long #define int ll using namespace std; const int N = 100005; int dp[N][105],a[N]; main (){ ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int n,k; cin>>n>>k; for (int i = 1; i <= n; i++) cin>>a[i]; for (int i = 1; i <= n; i++) for (int j = 0; j <= k; j++) dp[i][j] = 1e18; sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++){ for (int K = 2; K <= k; K++) for (int j = 1; j < i; j++) dp[i][K] = min(dp[i][K],dp[j][K - 1] + a[i]); dp[i][1] = a[i]; } cout<<dp[n][k]; }

Compilation message (stderr)

blocks.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main (){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...