結果

問題 No.733 分身並列コーディング
ユーザー akakimidoriakakimidori
提出日時 2019-03-18 16:35:51
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 183 ms / 1,500 ms
コード長 560 bytes
コンパイル時間 974 ms
コンパイル使用メモリ 29,320 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 14:12:06
合計ジャッジ時間 6,441 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 182 ms
4,376 KB
testcase_04 AC 183 ms
4,376 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 168 ms
4,376 KB
testcase_08 AC 152 ms
4,380 KB
testcase_09 AC 62 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 22 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 62 ms
4,376 KB
testcase_20 AC 62 ms
4,376 KB
testcase_21 AC 22 ms
4,376 KB
testcase_22 AC 181 ms
4,380 KB
testcase_23 AC 22 ms
4,376 KB
testcase_24 AC 21 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 152 ms
4,376 KB
testcase_29 AC 181 ms
4,376 KB
testcase_30 AC 181 ms
4,376 KB
testcase_31 AC 183 ms
4,376 KB
testcase_32 AC 8 ms
4,380 KB
testcase_33 AC 8 ms
4,380 KB
testcase_34 AC 8 ms
4,376 KB
testcase_35 AC 8 ms
4,376 KB
testcase_36 AC 8 ms
4,376 KB
testcase_37 AC 8 ms
4,380 KB
testcase_38 AC 182 ms
4,376 KB
testcase_39 AC 182 ms
4,376 KB
testcase_40 AC 181 ms
4,380 KB
testcase_41 AC 8 ms
4,376 KB
testcase_42 AC 8 ms
4,376 KB
testcase_43 AC 8 ms
4,380 KB
testcase_44 AC 182 ms
4,376 KB
testcase_45 AC 181 ms
4,380 KB
testcase_46 AC 181 ms
4,376 KB
testcase_47 AC 181 ms
4,376 KB
testcase_48 AC 181 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

void run(void){
  int t,n;
  scanf("%d%d",&t,&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int *dp=(int *)calloc(1<<n,sizeof(int));
  for(i=1;i<(1<<n);i++){
    int sum=0;
    int j;
    for(j=0;j<n;j++) if((i>>j)&1) sum+=a[j];
    if(sum<=t){
      dp[i]=1;
      continue;
    }
    int min=n;
    for(j=i&(i-1);j>0;j=(j-1)&i){
      int m=dp[j]+dp[i^j];
      if(min>m) min=m;
    }
    dp[i]=min;
  }
  printf("%d\n",dp[(1<<n)-1]);
}

int main(void){
  run();
  return 0;
}
0