結果

問題 No.2701 A cans -> B cans
ユーザー 👑 chro_96chro_96
提出日時 2024-03-29 23:01:46
言語 C
(gcc 12.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 888 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 31,232 KB
実行使用メモリ 197,368 KB
最終ジャッジ日時 2024-04-16 02:24:29
合計ジャッジ時間 50,125 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
197,304 KB
testcase_01 AC 135 ms
197,300 KB
testcase_02 AC 136 ms
197,292 KB
testcase_03 AC 132 ms
197,276 KB
testcase_04 AC 133 ms
197,272 KB
testcase_05 AC 132 ms
197,280 KB
testcase_06 AC 133 ms
197,356 KB
testcase_07 AC 134 ms
197,324 KB
testcase_08 AC 133 ms
197,316 KB
testcase_09 AC 134 ms
197,260 KB
testcase_10 AC 133 ms
197,288 KB
testcase_11 AC 133 ms
197,284 KB
testcase_12 AC 133 ms
197,260 KB
testcase_13 AC 132 ms
197,324 KB
testcase_14 AC 134 ms
197,316 KB
testcase_15 AC 132 ms
197,292 KB
testcase_16 AC 133 ms
197,344 KB
testcase_17 AC 133 ms
197,292 KB
testcase_18 AC 132 ms
197,272 KB
testcase_19 AC 133 ms
197,328 KB
testcase_20 AC 133 ms
197,336 KB
testcase_21 AC 134 ms
197,292 KB
testcase_22 AC 133 ms
197,124 KB
testcase_23 AC 132 ms
197,120 KB
testcase_24 AC 133 ms
197,240 KB
testcase_25 AC 134 ms
197,348 KB
testcase_26 AC 584 ms
197,332 KB
testcase_27 AC 587 ms
197,236 KB
testcase_28 AC 649 ms
197,308 KB
testcase_29 AC 983 ms
197,272 KB
testcase_30 TLE -
testcase_31 AC 992 ms
197,288 KB
testcase_32 AC 992 ms
197,340 KB
testcase_33 AC 987 ms
197,328 KB
testcase_34 AC 996 ms
197,284 KB
testcase_35 AC 988 ms
197,368 KB
testcase_36 AC 982 ms
197,256 KB
testcase_37 AC 972 ms
197,296 KB
testcase_38 AC 970 ms
197,360 KB
testcase_39 AC 973 ms
197,328 KB
testcase_40 AC 987 ms
197,332 KB
testcase_41 AC 969 ms
197,300 KB
testcase_42 AC 982 ms
197,168 KB
testcase_43 AC 988 ms
197,344 KB
testcase_44 AC 987 ms
197,280 KB
testcase_45 TLE -
testcase_46 AC 986 ms
197,288 KB
testcase_47 AC 978 ms
197,304 KB
testcase_48 AC 977 ms
197,284 KB
testcase_49 TLE -
testcase_50 TLE -
testcase_51 TLE -
testcase_52 TLE -
testcase_53 TLE -
testcase_54 TLE -
testcase_55 TLE -
testcase_56 AC 998 ms
197,248 KB
testcase_57 TLE -
testcase_58 TLE -
testcase_59 AC 133 ms
197,272 KB
testcase_60 AC 132 ms
197,248 KB
testcase_61 AC 134 ms
197,172 KB
testcase_62 AC 134 ms
197,296 KB
testcase_63 AC 133 ms
197,344 KB
testcase_64 AC 134 ms
197,244 KB
testcase_65 AC 133 ms
197,320 KB
testcase_66 AC 134 ms
197,288 KB
testcase_67 AC 133 ms
197,292 KB
testcase_68 AC 133 ms
197,320 KB
testcase_69 TLE -
testcase_70 TLE -
testcase_71 TLE -
testcase_72 TLE -
testcase_73 TLE -
testcase_74 TLE -
testcase_75 TLE -
testcase_76 TLE -
testcase_77 TLE -
testcase_78 TLE -
権限があれば一括ダウンロードができます

ソースコード

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 ans[5001] = {};
  long long dp[5000][5001] = {};
  
  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++) {
    for (int j = 0; j < n; j++) {
      if (i+1 >= a[j] && ans[i+1] < dp[j][i+1-a[j]]+((long long)b[j])*c[j]) {
        ans[i+1] = dp[j][i+1-a[j]]+((long long)b[j])*c[j];
      }
    }
    for (int j = 0; j < n; j++) {
      dp[j][i+1] = ans[i+1];
      if (i+1 >= a[j]-b[j] && dp[j][i+1] < dp[j][i+1-a[j]+b[j]]+((long long)b[j])*c[j]) {
        dp[j][i+1] = dp[j][i+1-a[j]+b[j]]+((long long)b[j])*c[j];
      }
    }
    printf("%lld\n", ans[i+1]);
  }
  
  return 0;
}
0