結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2016-02-26 22:37:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 285 bytes |
コンパイル時間 | 1,660 ms |
コンパイル使用メモリ | 161,244 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 08:17:28 |
合計ジャッジ時間 | 2,283 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d%d", &l, &n); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | rep(i,n) scanf("%d",w+i); | ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) using namespace std; int l, n; int w[10000]; int main(){ scanf("%d%d", &l, &n); rep(i,n) scanf("%d",w+i); sort(w,w+n); int ans = 0; rep(i,n){ l -= w[i]; if(l < 0) break; ans++; } printf("%d\n", ans); }