結果
問題 | No.158 奇妙なお使い |
ユーザー | ぴろず |
提出日時 | 2015-02-27 00:28:00 |
言語 | C90 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 689 ms / 5,000 ms |
コード長 | 1,133 bytes |
コンパイル時間 | 670 ms |
コンパイル使用メモリ | 23,296 KB |
実行使用メモリ | 45,952 KB |
最終ジャッジ日時 | 2024-06-28 22:21:52 |
合計ジャッジ時間 | 3,467 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
44,852 KB |
testcase_01 | AC | 36 ms
45,056 KB |
testcase_02 | AC | 33 ms
44,928 KB |
testcase_03 | AC | 32 ms
44,928 KB |
testcase_04 | AC | 689 ms
45,952 KB |
testcase_05 | AC | 26 ms
44,928 KB |
testcase_06 | AC | 32 ms
44,928 KB |
testcase_07 | AC | 32 ms
44,928 KB |
testcase_08 | AC | 32 ms
44,800 KB |
testcase_09 | AC | 32 ms
44,928 KB |
testcase_10 | AC | 33 ms
44,800 KB |
testcase_11 | AC | 33 ms
44,800 KB |
testcase_12 | AC | 32 ms
44,800 KB |
testcase_13 | AC | 32 ms
44,928 KB |
testcase_14 | AC | 35 ms
44,928 KB |
testcase_15 | AC | 44 ms
44,928 KB |
testcase_16 | AC | 40 ms
44,928 KB |
testcase_17 | AC | 93 ms
45,056 KB |
testcase_18 | AC | 38 ms
45,184 KB |
testcase_19 | AC | 32 ms
44,928 KB |
testcase_20 | AC | 36 ms
44,928 KB |
testcase_21 | AC | 32 ms
45,312 KB |
testcase_22 | AC | 33 ms
45,952 KB |
testcase_23 | AC | 34 ms
44,928 KB |
testcase_24 | AC | 33 ms
44,800 KB |
testcase_25 | AC | 32 ms
44,928 KB |
testcase_26 | AC | 35 ms
44,928 KB |
testcase_27 | AC | 32 ms
44,800 KB |
testcase_28 | AC | 64 ms
44,800 KB |
testcase_29 | AC | 33 ms
44,800 KB |
testcase_30 | AC | 66 ms
44,928 KB |
コンパイルメッセージ
main.c: In function ‘main’: main.c:43:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 43 | scanf("%d",&a1000); | ^~~~~~~~~~~~~~~~~~ main.c:44:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 44 | scanf("%d",&a100); | ^~~~~~~~~~~~~~~~~ main.c:45:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 45 | scanf("%d",&a1); | ^~~~~~~~~~~~~~~ main.c:46:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 46 | scanf("%d",&db); | ^~~~~~~~~~~~~~~ main.c:47:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | scanf("%d",&b1000); | ^~~~~~~~~~~~~~~~~~ main.c:48:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 48 | scanf("%d",&b100); | ^~~~~~~~~~~~~~~~~ main.c:49:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 49 | scanf("%d",&b1); | ^~~~~~~~~~~~~~~ main.c:50:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 50 | scanf("%d",&dc); | ^~~~~~~~~~~~~~~ main.c:51:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 51 | scanf("%d",&c1000); | ^~~~~~~~~~~~~~~~~~ main.c:52:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 52 | scanf("%d",&c100); | ^~~~~~~~~~~~~~~~~ main.c:53:9: warning: ignori
ソースコード
#include <stdio.h> #include <math.h> int a1000; int a100; int a1; int b1000; int b100; int b1; int db; int c1000; int c100; int c1; int dc; int dp[11][101][10001]; int max(int a,int b) { return a > b ? a : b; } int dfs(int a,int b,int c) { int i,j; if (a < 0 || b < 0 || c < 0) { return 0; //苦し紛れ } if (dp[a][b][c] >= 0) { return dp[a][b][c]; } int ret = 0; for(i=0;i<=a;i++) { for(j=0;j<=b;j++) { int bx = db - i * 1000 - j * 100; if (bx >= 0 && bx <= c) { ret = max(ret, dfs(a-i+b1000, b-j+b100, c-bx+b1) + 1); } int cx = dc - i * 1000 - j * 100; if (cx >= 0 && cx <= c) { ret = max(ret, dfs(a-i+c1000, b-j+c100, c-cx+c1) + 1); } } } return dp[a][b][c] = ret; } int main() { scanf("%d",&a1000); scanf("%d",&a100); scanf("%d",&a1); scanf("%d",&db); scanf("%d",&b1000); scanf("%d",&b100); scanf("%d",&b1); scanf("%d",&dc); scanf("%d",&c1000); scanf("%d",&c100); scanf("%d",&c1); int i,j,k; for(i=0;i<=10;i++) { for(j=0;j<=100;j++) { for(k=0;k<=10000;k++) { dp[i][j][k] = -1; } } } printf("%d\n",dfs(a1000,a100,a1)); return 0; }