# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1171174 | kiennguyendinh | K blocks (IZhO14_blocks) | C++20 | 0 ms | 400 KiB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
int n,k;
int a[1000005];
int rmq[1000005][20];
long long dp[101][1000005];
int get(int l,int r){
int v = __lg(r - l + 1);
return max(rmq[l][v],rmq[r - (1 << v) + 1][v]);
}
void dnc(int lim,int l,int r,int optl,int optr){
if(l > r) return;
int mid = (l + r)/2;
long long bV = LLONG_MAX,bP,cost;
for(int i = optl;i <= min(mid - 1,optr);i++){
cost = get(i + 1,mid) + dp[lim - 1][i];
if(cost < bV){
bV = cost;
bP = i;
}
}
dp[lim][mid] = bV;
dnc(lim,l,mid - 1,optl,bP);
dnc(lim,mid + 1,r,bP,optr);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |