結果

問題 No.5 数字のブロック
ユーザー takatowintakatowin
提出日時 2017-01-06 23:32:21
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 508 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 30,976 KB
実行使用メモリ 8,604 KB
最終ジャッジ日時 2024-05-09 21:12:16
合計ジャッジ時間 6,589 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,812 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |   scanf("%d %d",&L,&N);
      |   ~~~~~^~~~~~~~~~~~~~~
main.cpp:26:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |     scanf("%d",&b[i]);
      |     ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int L,N;
int max(int a,int b){
 return (a>b ? a : b);
}

int saiki(int temp,int f,int* b,int n){
  int i=0;
  if(f>L)
    return temp-1;
  else{
    if(n!=0)
      return max(saiki(temp,f,b,n-1),saiki(temp+1,f+b[N-n],b,n-1));
    else
      return temp;
  }
}
int main(void){
  int i=0;
  scanf("%d %d",&L,&N);
  int b[N];
  for(;i<N;i++){
    scanf("%d",&b[i]);
  }
  printf("%d\n",max(saiki(0,0,b,N),saiki(1,b[0],b,N)));
return 0;
}
0