Submission #100537

#TimeUsernameProblemLanguageResultExecution timeMemory
1005371KhanK blocks (IZhO14_blocks)C++14
18 / 100
1084 ms384 KiB
/// 1n the name of GOD #include <iostream> #include <stdio.h> #include <cmath> #include <algorithm> #include <cstdlib> #include <cstdio> using namespace std; #define ko exit(0); #define nl '\n' #define ios ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0); #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() #define oll(s, n, c) (s) + (c), s + (n) + c #define pb push_back #define ff first #define ss second #define pii pair<int, int> typedef long long ll; typedef double db; const int N = 1e5 + 111; const int M = 1e9 + 7; int n, k; int a[N]; int calc(int v = 1, int cnt = k) { if (v > n) { if (cnt != 0) return 1e9; return 0; } if (cnt < 0) return 1e9; int res = 1e9; int mx = 0; for (int i = v; i <= n - cnt + 1; i++) { mx = max(mx, a[i]); res = min(res, calc(i + 1, cnt - 1) + mx); } return res; } int main(){ cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } cout << calc(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...