結果

問題 No.332 数列をプレゼントに
ユーザー GrenacheGrenache
提出日時 2015-12-25 22:25:58
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 2,737 bytes
コンパイル時間 5,155 ms
コンパイル使用メモリ 80,500 KB
実行使用メモリ 473,564 KB
最終ジャッジ日時 2023-10-19 03:50:41
合計ジャッジ時間 8,732 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 58 ms
53,764 KB
testcase_02 AC 59 ms
52,816 KB
testcase_03 AC 61 ms
53,772 KB
testcase_04 AC 60 ms
52,808 KB
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;


public class Main_yukicoder332 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Printer pr = new Printer(System.out);

        int n = sc.nextInt();
        long x = sc.nextLong();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }

        Map<Long, List<Integer>> hm = new HashMap<Long, List<Integer>>();
        hm.put(0L, new ArrayList<Integer>());

        for (int i = 0; i < n; i++) {
            Map<Long, List<Integer>> hm2 = new HashMap<Long, List<Integer>>();
        	for (Entry<Long, List<Integer>> e : hm.entrySet()) {
        		if (!hm.containsKey(e.getKey() + a[i])) {
        			ArrayList<Integer> tmp = new ArrayList<Integer>(e.getValue());
        			tmp.add(i);
        			hm2.put(e.getKey() + a[i], tmp);
        		}
        	}
        	hm.putAll(hm2);
        }

        if (hm.containsKey(x)) {
        	List<Integer> ret = hm.get(x);
        	int j = 0;
        	StringBuilder tmp = new StringBuilder();
        	for (int i = 0; i < n; i++) {
        		if (i == ret.get(j)) {
        			tmp.append('o');
        			j++;
        		} else {
        			tmp.append('x');
        		}
        	}
        	pr.println(tmp);
        } else {
        	pr.println("No");
        }

        pr.close();
        sc.close();
    }

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0