結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2018-11-22 18:24:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 666 bytes |
| コンパイル時間 | 811 ms |
| コンパイル使用メモリ | 54,616 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-24 17:44:44 |
| 合計ジャッジ時間 | 3,351 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 WA * 1 |
ソースコード
#include <iostream>
#include <string>
#define N 10000
using namespace std;
void sort(int n, int a[]) {
int i, j, tmp;
for (i=0; i<=n-2; i++) {
for (j=i+1; j<n; j++) {
if (a[i] > a[j]) {
tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
}
}
}
int main() {
int i, width, n, a[N], sum=0, count=0;
cin >> width >> n;
for (i=0; i<n; i++) {
cin >> a[i];
}
sort(n, a);
while (sum <= width) {
sum += a[count];
count++;
if (count == n) break;
}
if (count != n) sum -= a[--count];
cout << count << endl;
return 0;
}