| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1104098 | dophu | K blocks (IZhO14_blocks) | C++17 | 1069 ms | 83800 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
const ll inf=1e17;
const ll N=1e5+2;
const ll blocks=1e2+2;
ll dp[N][blocks];
ll rm[N][32];
ll a[N];
ll n,k;
void build(ll lgg) {
for (ll i=1;i<=lgg;i++) {
for (ll j=1;j+(1<<i)-1<=n;j++) {
rm[j][i]=max(rm[j][i-1],rm[j+(1<<(i-1))][i-1]);
}
}
}
ll get(ll l,ll r) {
ll k=__lg(r-l+1);
return max(rm[l][k],rm[r-(1<<k)+1][k]);
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("blocks.in","r")) {
freopen("blocks.in","r",stdin);
freopen("blocks.out","w",stdout);
}
memset(dp,0x3f3f,sizeof(dp));
cin>>n>>k;
for (ll i=1;i<=n;i++) {
cin>>a[i];
rm[i][0]=a[i];
}
build(__lg(n));
for (ll i=1;i<=n;i++) {
dp[i][1]=get(1,i);
}
for (ll i=2;i<=n;i++) {
for (ll j=2;j<=min(i,k);j++) {
for (ll g=j-1;g<=i-1;g++) {
dp[i][j]=min(dp[i][j],dp[g][j-1]+get(g+1,i));
}
}
}
cout<<dp[n][k];
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
