結果

問題 No.5 数字のブロック
コンテスト
ユーザー dododondon111
提出日時 2017-03-16 15:39:54
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 525 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 179 ms
コンパイル使用メモリ 38,368 KB
最終ジャッジ日時 2026-02-21 23:32:02
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>
#include<stdlib.h>

int int_sort( const void * a , const void * b ) {
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}

int main(){
  int l,n,i;
  int count=0;
  int *x;

  scanf("%d",&l);
  scanf("%d",&n);

  x = calloc(n,sizeof(int));

  for(i=0;i<n;i++)
    scanf("%d",&x[i]);

  qsort(x,n,sizeof(int),int_sort);

  i=0;
  do{
    l = l-x[i];
    i++;
    count++;
  }while(l>0);

  printf("%d\n",count-1);

  return 0;
}
0