結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2014-11-30 20:36:09 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 366 bytes |
コンパイル時間 | 364 ms |
コンパイル使用メモリ | 36,192 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 07:26:27 |
合計ジャッジ時間 | 1,520 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf( "%d%d", &L, &N ); | ~~~~~^~~~~~~~~~~~~~~~~~ main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf( "%d", W+i ); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio> #include<algorithm> #define rep(i,a) for(int i=0;i<(a);++i) const int MAX_N = 10000; int L, N, W[MAX_N]; int main() { scanf( "%d%d", &L, &N ); rep( i, N ) scanf( "%d", W+i ); std::sort( W, W+N ); int sum = 0; rep( i, N ) { if( sum+W[i] > L ) { printf( "%d\n", i ); break; } sum += W[i]; } return 0; }