結果
問題 | No.5 数字のブロック |
ユーザー |
|
提出日時 | 2023-05-28 20:52:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 250 ms / 5,000 ms |
コード長 | 559 bytes |
コンパイル時間 | 807 ms |
コンパイル使用メモリ | 64,256 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 18:34:03 |
合計ジャッジ時間 | 3,906 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <iostream> using namespace std; int main() { int L, N, tmp, sum = 0; cin >> L >> N; int W[N]; for(int i = 0; i < sizeof(W)/sizeof(W[0]); i++){ cin >> W[i]; } for(int i = 0; i < N; i++){ for(int j = i + 1; j < N; j++){ if(W[i] > W[j]){ tmp = W[i]; W[i] = W[j]; W[j] = tmp; } } } int count = 0; while(L >= W[count] && count < N){ L -= W[count]; count++; } cout << count << endl; return 0; }