結果

問題 No.5 数字のブロック
コンテスト
ユーザー Projectormato
提出日時 2018-01-07 22:50:45
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 496 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,011 ms
コンパイル使用メモリ 183,264 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-12 23:53:47
合計ジャッジ時間 2,201 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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:8:28: note: in definition of macro 'puts'
    8 | #define puts(x) x; cout << x << endl;
      |                            ^
main.cpp:13:13: note: 'result' was declared here
   13 |   int l, n, result;
      |             ^~~~~~

ソースコード

diff #
raw source code

#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)
}
0