提出詳細


ソースコード

String inputLines[] = loadStrings("J.txt");      // 入力ファイルの指定
PrintWriter output = createWriter("output.txt"); // 出力ファイルの指定
int T = int(inputLines[0]);   // 1行目の入力を取得して、int型に変換する

int[][] menu;
int useMoney;
int eatWeight;
int c;
int money;

// 実際の処理をT回繰り返す
int line = 1;
void setup(){
for(int i = 1; i <= T; i++) {
  output.println("Case #" + (i) + ":");
  c = int(inputLines[line++]);
  money = int(inputLines[line++]);
  
  menu = new int[c][2];
  useMoney = 0;
  eatWeight = 0;
  
  for(int j = 0; j < c; j++){
    int[] t = new int[2];
    t = int(split(inputLines[line++], " "));
    menu[j][0] = t[0];
    menu[j][1] = t[1];
  }
  
  eat(0, 0, 0);
  output.println(useMoney + " " + eatWeight);
}
output.flush();   // ファイルに書き込む
output.close();   // ファイルを閉じる
exit();
}

void eat(int n, int useM, int eatW){
  if( useMoney < useM){
    useMoney = useM;
    eatWeight = eatW;
  }
  for(int i = n; i < c; i++){
    if(useM + menu[i][0] <= money){
      eat(i+1, useM + menu[i][0], eatW + menu[i][1]);
    }
  }
}

提出情報

提出時間 2019-11-30 19:29:06
問題 I - 質より量 (small)
ユーザ名 rn_magi
状態 不正解
正解率 27/50
提出出力結果

テストケース情報

# 状態 詳細情報
テストケース 1 正解 詳細を見る
テストケース 2 不正解 詳細を見る
テストケース 3 正解 詳細を見る
テストケース 4 正解 詳細を見る
テストケース 5 不正解 詳細を見る
テストケース 6 正解 詳細を見る
テストケース 7 不正解 詳細を見る
テストケース 8 不正解 詳細を見る
テストケース 9 正解 詳細を見る
テストケース 10 正解 詳細を見る
テストケース 11 正解 詳細を見る
テストケース 12 不正解 詳細を見る
テストケース 13 正解 詳細を見る
テストケース 14 不正解 詳細を見る
テストケース 15 不正解 詳細を見る
テストケース 16 正解 詳細を見る
テストケース 17 正解 詳細を見る
テストケース 18 正解 詳細を見る
テストケース 19 正解 詳細を見る
テストケース 20 正解 詳細を見る
テストケース 21 正解 詳細を見る
テストケース 22 正解 詳細を見る
テストケース 23 不正解 詳細を見る
テストケース 24 正解 詳細を見る
テストケース 25 正解 詳細を見る
テストケース 26 正解 詳細を見る
テストケース 27 不正解 詳細を見る
テストケース 28 不正解 詳細を見る
テストケース 29 正解 詳細を見る
テストケース 30 正解 詳細を見る
テストケース 31 不正解 詳細を見る
テストケース 32 正解 詳細を見る
テストケース 33 不正解 詳細を見る
テストケース 34 不正解 詳細を見る
テストケース 35 不正解 詳細を見る
テストケース 36 不正解 詳細を見る
テストケース 37 不正解 詳細を見る
テストケース 38 不正解 詳細を見る
テストケース 39 不正解 詳細を見る
テストケース 40 不正解 詳細を見る
テストケース 41 不正解 詳細を見る
テストケース 42 不正解 詳細を見る
テストケース 43 正解 詳細を見る
テストケース 44 正解 詳細を見る
テストケース 45 不正解 詳細を見る
テストケース 46 不正解 詳細を見る
テストケース 47 正解 詳細を見る
テストケース 48 正解 詳細を見る
テストケース 49 正解 詳細を見る
テストケース 50 正解 詳細を見る