結果

問題 No.2701 A cans -> B cans
ユーザー 👑 chro_96chro_96
提出日時 2024-05-11 13:39:38
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 646 ms / 1,000 ms
コード長 865 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 30,336 KB
実行使用メモリ 197,320 KB
最終ジャッジ日時 2024-05-11 13:40:08
合計ジャッジ時間 27,094 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
197,092 KB
testcase_01 AC 68 ms
197,104 KB
testcase_02 AC 51 ms
197,176 KB
testcase_03 AC 50 ms
197,112 KB
testcase_04 AC 50 ms
197,236 KB
testcase_05 AC 51 ms
197,156 KB
testcase_06 AC 51 ms
197,164 KB
testcase_07 AC 51 ms
197,156 KB
testcase_08 AC 49 ms
197,152 KB
testcase_09 AC 51 ms
197,172 KB
testcase_10 AC 50 ms
197,292 KB
testcase_11 AC 50 ms
197,252 KB
testcase_12 AC 51 ms
197,200 KB
testcase_13 AC 49 ms
197,316 KB
testcase_14 AC 50 ms
197,244 KB
testcase_15 AC 50 ms
197,200 KB
testcase_16 AC 51 ms
197,288 KB
testcase_17 AC 51 ms
197,180 KB
testcase_18 AC 50 ms
197,092 KB
testcase_19 AC 49 ms
197,252 KB
testcase_20 AC 50 ms
197,156 KB
testcase_21 AC 50 ms
197,136 KB
testcase_22 AC 49 ms
197,224 KB
testcase_23 AC 50 ms
197,288 KB
testcase_24 AC 50 ms
197,180 KB
testcase_25 AC 50 ms
197,136 KB
testcase_26 AC 127 ms
197,200 KB
testcase_27 AC 129 ms
197,292 KB
testcase_28 AC 128 ms
197,252 KB
testcase_29 AC 593 ms
197,268 KB
testcase_30 AC 570 ms
197,248 KB
testcase_31 AC 579 ms
197,220 KB
testcase_32 AC 576 ms
197,256 KB
testcase_33 AC 561 ms
197,276 KB
testcase_34 AC 572 ms
197,296 KB
testcase_35 AC 558 ms
197,104 KB
testcase_36 AC 591 ms
197,204 KB
testcase_37 AC 567 ms
197,308 KB
testcase_38 AC 585 ms
197,144 KB
testcase_39 AC 577 ms
197,244 KB
testcase_40 AC 591 ms
197,168 KB
testcase_41 AC 560 ms
197,244 KB
testcase_42 AC 599 ms
197,256 KB
testcase_43 AC 556 ms
197,236 KB
testcase_44 AC 586 ms
197,172 KB
testcase_45 AC 563 ms
197,168 KB
testcase_46 AC 584 ms
197,200 KB
testcase_47 AC 568 ms
197,216 KB
testcase_48 AC 576 ms
197,296 KB
testcase_49 AC 621 ms
197,216 KB
testcase_50 AC 638 ms
197,280 KB
testcase_51 AC 584 ms
197,264 KB
testcase_52 AC 604 ms
197,132 KB
testcase_53 AC 604 ms
197,252 KB
testcase_54 AC 603 ms
197,188 KB
testcase_55 AC 613 ms
197,272 KB
testcase_56 AC 614 ms
197,212 KB
testcase_57 AC 639 ms
197,276 KB
testcase_58 AC 646 ms
197,168 KB
testcase_59 AC 50 ms
197,216 KB
testcase_60 AC 49 ms
197,160 KB
testcase_61 AC 50 ms
197,284 KB
testcase_62 AC 50 ms
197,124 KB
testcase_63 AC 49 ms
197,276 KB
testcase_64 AC 50 ms
197,320 KB
testcase_65 AC 49 ms
197,104 KB
testcase_66 AC 50 ms
197,140 KB
testcase_67 AC 50 ms
197,232 KB
testcase_68 AC 50 ms
197,284 KB
testcase_69 AC 392 ms
197,208 KB
testcase_70 AC 378 ms
197,172 KB
testcase_71 AC 368 ms
197,168 KB
testcase_72 AC 376 ms
197,304 KB
testcase_73 AC 360 ms
197,108 KB
testcase_74 AC 330 ms
197,260 KB
testcase_75 AC 329 ms
197,228 KB
testcase_76 AC 333 ms
197,180 KB
testcase_77 AC 368 ms
197,088 KB
testcase_78 AC 331 ms
197,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  int m = 0;
  int a[5000] = {};
  int b[5000] = {};
  long long c[5000] = {};
  
  int res = 0;
  
  long long dp[5001][5000] = {};
  
  res = scanf("%d", &n);
  res = scanf("%d", &m);
  for (int i = 0; i < n; i++) {
    res = scanf("%d", a+i);
    res = scanf("%d", b+i);
    res = scanf("%lld", c+i);
  }
  
  for (int i = 0; i < m; i++) {
    long long ans = 0LL;
    for (int j = 0; j < n; j++) {
      if (i+1 >= a[j] && ans < dp[i+1-a[j]][j]+((long long)b[j])*c[j]) {
        ans = dp[i+1-a[j]][j]+((long long)b[j])*c[j];
      }
    }
    for (int j = 0; j < n; j++) {
      dp[i+1][j] = ans;
      if (i+1 >= a[j]-b[j] && dp[i+1][j] < dp[i+1-a[j]+b[j]][j]+((long long)b[j])*c[j]) {
        dp[i+1][j] = dp[i+1-a[j]+b[j]][j]+((long long)b[j])*c[j];
      }
    }
    printf("%lld\n", ans);
  }
  
  return 0;
}
0