結果

問題 No.5 数字のブロック
ユーザー neeet
提出日時 2017-06-15 15:55:39
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 426 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 29,568 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-18 11:13:15
合計ジャッジ時間 1,162 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main(void)
{
  int l, n, i, j, cnt = 0, sum = 0;

  scanf("%d%d", &l, &n);
  int w[n];
  for(i = 0; i < n; i++)
    scanf("%d", &w[i]);
  for(i = 1; cnt < n; i++){
    for(j = 0; j < n; j++){
      if(w[j] == i){
        sum += i;
        if(sum > l){
          goto end;
//          printf("%d\n", cnt);
//          return 0;
        }
        cnt++;
      }
    }
  }
  end:;
  printf("%d\n", cnt);
}
0