結果

問題 No.733 分身並列コーディング
ユーザー weizen
提出日時 2018-09-07 23:11:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 684 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 37,188 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-29 19:36:16
合計ジャッジ時間 1,329 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d %d",&T,&N);
      |         ~~~~~^~~~~~~~~~~~~~~
main.cpp:10:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         for(int i = 0; i < N; i++) scanf("%d",t+i);
      |                                    ~~~~~^~~~~~~~~~

ソースコード

diff #

#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