結果

問題 No.733 分身並列コーディング
コンテスト
ユーザー weizen
提出日時 2018-09-07 23:11:29
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 684 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 270 ms
コンパイル使用メモリ 55,296 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-23 12:53:17
合計ジャッジ時間 1,703 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <string.h>
#include <algorithm>

int T,N;
int t[17];

int main(){
        scanf("%d %d",&T,&N);
        for(int i = 0; i < N; i++) scanf("%d",t+i);

        std::sort(t,t+N);
        char used[17];
        memset(used,0,sizeof(used));
        int ans = 0;
        for(int e = N-1; e >= 0; e--){
                if(used[e]) break;
                used[e] = 1;
                ans++;
                for(int s = 0; s < N; s++){
                        if(!used[s] && t[e]+t[s] <= T){
                                t[e] += t[s];
                                used[s] = 1;
                        }
                }
        }
        printf("%d\n",ans);
}
0