結果
| 問題 | 
                            No.5 数字のブロック
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Projectormato
                         | 
                    
| 提出日時 | 2018-01-07 22:50:45 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 496 bytes | 
| コンパイル時間 | 1,435 ms | 
| コンパイル使用メモリ | 168,828 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-18 11:55:26 | 
| 合計ジャッジ時間 | 2,348 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 24 WA * 10 | 
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:25:8: warning: 'result' may be used uninitialized [-Wmaybe-uninitialized]
   25 |   puts(result)
      |        ^~~~~~
main.cpp:13:13: note: 'result' was declared here
   13 |   int l, n, result;
      |             ^~~~~~
            
            ソースコード
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
int main(){
  int l, n, result;
  cin >> l >> n;
  int w[n];
  list_input(w, n)
  sort(w,w+n);
  rep(i,n){
    l -= w[i];
    if (0 > l) {
      result = i;
      break;
    }
  }
  puts(result)
}
            
            
            
        
            
Projectormato