結果

問題 No.5 数字のブロック
ユーザー naniwha12naniwha12
提出日時 2019-01-29 00:39:55
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 845 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 56,312 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-07 04:49:15
合計ジャッジ時間 3,297 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int l, n;
void
sort(int* a) {
        int t; 
        int i, f = 1; 
        while (f && n >= 0) {
                f = 0; 
                for (i = 0; i < n-1; i++) {
                        if (a[i] > a[i+1]) {
                                a[i]   ^= a[i+1];
                                a[i+1] ^= a[i];
                                a[i]   ^= a[i+1];
                                f = 1;
                        }
                }
        }
        for (i = 0; i < n; i++) cerr << a[i] << " ";
}
int
main() {
        cin >> l >> n;
        int w[n];
        int i;
        for (i = 0; i < n; i++) cin >> w[i];
        sort(w);
        for (i = 0; l >= 0 && i < n; i++)
                l -= w[i];
        if (l = 0) cout << i + 1 << endl;
        else cout << i-1 << endl;
        return 0;
}
0