結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2014-11-30 20:36:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 391 bytes |
コンパイル時間 | 239 ms |
コンパイル使用メモリ | 36,196 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 07:26:32 |
合計ジャッジ時間 | 1,071 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 24 |
コンパイルメッセージ
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]; } printf( "%d\n", N ); return 0; }