結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2018-11-22 18:18:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 619 bytes |
コンパイル時間 | 494 ms |
コンパイル使用メモリ | 54,232 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 17:43:55 |
合計ジャッジ時間 | 3,253 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 10 |
ソースコード
#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++; } sum -= a[--count]; cout << count << endl; return 0; }