結果
| 問題 | 
                            No.5 数字のブロック
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-08-08 09:26:02 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 965 bytes | 
| コンパイル時間 | 1,581 ms | 
| コンパイル使用メモリ | 157,076 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-12 00:08:33 | 
| 合計ジャッジ時間 | 5,245 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 WA * 3 RE * 21 | 
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:18:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |   scanf("%d %d",&L,&N);  //大きな箱とブロックの数の入力
      |   ~~~~~^~~~~~~~~~~~~~~
main.cpp:22:11: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |      scanf("%d",&w);
      |      ~~~~~^~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
int sort(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
using namespace std;
int main(int argc, char **argv) 
{
  int L;              //大きな箱
  int N;              //ブロックの数
  int W[100];         //各ブロックの幅の格納用
  int i;              //ループカウンタ
  int w;             //各ブロックの幅
  int count = 0;      //各ブロックの幅と大きな箱の比較用
  int c = 0;          //何個まで入るかのカウンタ
  scanf("%d %d",&L,&N);  //大きな箱とブロックの数の入力
  
  for(i=0;i<N;i++)       //各ブロックの幅の入力と格納
  {
     scanf("%d",&w);
     W[i] = w;
  }
  for(i=0;i<N;i++)       //sort
  {
    qsort(W,N,sizeof(int),sort);
  }
  for(i=0;i<N;i++)    //何個まで入るかのカウンタの処理
  {
       count +=W[i];
       if(count < L)
       {
        c++;
       }
  }
  printf("%d\n",c);
  return 0;
}