結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2020-05-11 23:32:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 267 bytes |
コンパイル時間 | 712 ms |
コンパイル使用メモリ | 42,368 KB |
最終ジャッジ日時 | 2025-01-10 10:28:20 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:15: 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:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | for (int i = 0; i < N; i++) scanf ("%d", &A[i]); | ~~~~~~^~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <algorithm> using namespace std; int L, N, A[10010]; int main() { scanf ("%d %d", &L, &N); for (int i = 0; i < N; i++) scanf ("%d", &A[i]); sort(A, A + N); int c = 0; while (A[c] <= L) L -= A[c++]; printf ("%d\n", c); return 0; }