結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
shimashima_k
|
| 提出日時 | 2015-04-25 12:30:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 91 ms / 5,000 ms |
| コード長 | 614 bytes |
| コンパイル時間 | 397 ms |
| コンパイル使用メモリ | 60,920 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-17 22:40:49 |
| 合計ジャッジ時間 | 1,847 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main() {
int L, N, ans = 0;
vector<int> W;
cin >> L;
cin >> N;
while (N--) {
int a;
cin>>a;
W.push_back(a);
}
for (int i=0; i<W.size(); i++){
for (int j= W.size() - 1; j > i; j--) {
if (W[i] > W[j]){
int t = W[i];
W[i] = W[j];
W[j] = t;
}
}
}
for (int i=0; i<W.size(); i++) {
if (L >= W[i]) {
L -= W[i];
ans++;
}
}
cout<<ans<<endl;
return 0;
}
shimashima_k