Submission #12175

#TimeUsernameProblemLanguageResultExecution timeMemory
12175imsifile배낭 문제 준비하기 (GA9_invknapsack)C++98
100 / 100
0 ms1092 KiB
#include<stdio.h> #define maxn 300 typedef long long lld; lld t, dy[303], mx; int mi, ba[303], n; int main(){ int i, j, a; dy[0]=1; scanf("%lld", &t); if(t==1){ printf("1 1\n1"); return 0; } for(i=0;; i++){ mx=0, mi=0; for(j=0; j<=maxn; j++){ if(mx<dy[j] && dy[j]<=t)mx=dy[j]; if(mx==dy[j])mi=j; } if(mx==t)break; if(mi==0)a=1; else{ for(a=1; a<=mi; a++){ if(dy[mi]+dy[mi-a]<=t)break; } } ba[i]=a; for(j=maxn; j>=a; j--){ if(dy[j]<=t)dy[j]+=dy[j-a]; } } n=i; printf("%d %d\n", n, mi); for(i=0; i<n; i++)printf("%d ", ba[i]); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...