結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2018-12-19 19:40:36 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 452 bytes |
コンパイル時間 | 467 ms |
コンパイル使用メモリ | 60,316 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-25 08:06:51 |
合計ジャッジ時間 | 1,947 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:17:38: warning: converting to non-pointer type ‘__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type’ {aka ‘int’} from NULL [-Wconversion-null] 17 | W[i]=NULL; | ^~~~ main.cpp:21:38: warning: converting to non-pointer type ‘__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type’ {aka ‘int’} from NULL [-Wconversion-null] 21 | W[j]=NULL; | ^~~~
ソースコード
#include<iostream> #include<vector> using namespace std; int main() { long long int N, L, min,num; cin >> L >> N; vector<int>W(N); num = 0; for (int i = 0; i<N; i++) { cin >> W[i]; } for (int i = 0; i<N; i++) { for (int j = 0; j<N; j++) { if (W[i]<=W[j]) { min = W[i]; W[i]=NULL; } else { min = W[j]; W[j]=NULL; } } if (L - min >= 0) { L = L - min; num++; } } cout << num << endl; return 0; }