結果

問題 No.1701 half price
ユーザー merlinmerlin
提出日時 2021-10-08 22:00:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 4,141 ms
コンパイル使用メモリ 73,664 KB
実行使用メモリ 53,028 KB
最終ジャッジ日時 2023-09-30 10:07:40
合計ジャッジ時間 7,654 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
49,372 KB
testcase_01 AC 36 ms
49,148 KB
testcase_02 AC 124 ms
50,924 KB
testcase_03 AC 38 ms
49,056 KB
testcase_04 AC 112 ms
51,240 KB
testcase_05 AC 40 ms
49,000 KB
testcase_06 AC 1,079 ms
51,784 KB
testcase_07 AC 950 ms
51,260 KB
testcase_08 WA -
testcase_09 AC 38 ms
49,176 KB
testcase_10 AC 38 ms
49,192 KB
testcase_11 AC 37 ms
49,200 KB
testcase_12 AC 39 ms
49,168 KB
testcase_13 AC 41 ms
48,928 KB
testcase_14 AC 37 ms
49,208 KB
testcase_15 AC 38 ms
49,152 KB
testcase_16 AC 41 ms
49,164 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 38 ms
49,312 KB
testcase_21 AC 863 ms
53,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),w=Integer.parseInt(s[1]);
        int i,j,k,ans=0,m=1<<n,a[]=new int[n];
        s=bu.readLine().split(" ");
        for(i=0;i<n;i++) a[i]=Integer.parseInt(s[i]);

        for(i=0;i<m;i++)
        for(j=0;j<m;j++)
        {
            long wt=0;
            for(k=0;k<n;k++)
            {
                int b1=(i>>k)&1,b2=(j>>k)&1;
                if(b1==0 && b2==1) {wt=-1; break;}
                if(b1==1)
                {
                    if(b2==0) wt+=a[k];
                    else wt+=a[k]/2;
                }
            }
            if(wt==w) {ans++; break;}
        }
        System.out.println(ans);
    }
}
0