| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 834224 | vjudge1 | K개의 묶음 (IZhO14_blocks) | C++17 | 1 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL n,k;
LL arr[1002];
LL dp[1000+2][102][2];// n k status
bool visited[1002][102][2];
LL f(LL idx,LL kelompok, LL status)
{
// printf("idx =%lld ,kelompok=%lld, status=%lld\n",idx,kelompok,status);
if(idx==n+1 && kelompok==k && status ==0)return 0;
if(kelompok>=k|| idx>n)return 1e18;
if(visited[idx][kelompok][status])return dp[idx][kelompok][status];
visited[idx][kelompok][status];
LL &dyn=dp[idx][kelompok][status];
dyn=1e18;
if(status==0)
{
dyn=min(dyn,f(idx+1,kelompok,1)+arr[idx]);
dyn=min(dyn,f(idx+1,kelompok+1,0)+arr[idx]);
}
else if(status==1)
{
dyn=min(dyn,f(idx+1,kelompok+1,0)+arr[idx]-arr[idx-1]);
// cout<<dyn<<endl;
dyn=min(dyn,f(idx+1,kelompok,status)+arr[idx]-arr[idx-1]);
// cout<<dyn<<endl;
}
// printf("dp[%lld][%lld][%lld]=%lld\n",idx,kelompok,status,dyn);
return dyn;
}
int main()
{
scanf("%lld %lld",&n,&k);
for(LL a=1;a<=n;a++)scanf("%lld",&arr[a]);
sort(arr+1,arr+n+1);
printf("%lld\n",f(1,0,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... | ||||
