結果

問題 No.5 数字のブロック
コンテスト
ユーザー takatowin
提出日時 2017-01-07 15:52:13
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 198 ms / 5,000 ms
コード長 534 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 332 ms
コンパイル使用メモリ 51,200 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-12 22:47:30
合計ジャッジ時間 2,963 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int L,N;
void bubble(int* b){
  int i,j,temp;
  for(i=N-1;i>0;i--){
    for(j=0;j<i;j++)
      if(b[j]>b[j+1]){
        temp=b[j];
        b[j]=b[j+1];
        b[j+1]=temp;
      }
  }
}
int main(void){
  int i=0,temp=0,temp1=0;
  scanf("%d %d",&L,&N);
  int b[N];
  for(;i<N;i++){
    scanf("%d",&b[i]);
  }
  bubble(b);
  for(i=0;i<N;i++){
    temp+=b[i];
    temp1++;
    if(temp>L){
      temp1--;
      break;
    }
  }
  printf("%d\n",temp1);
return 0;
}
0