Submission #51035730


Source Code Expand

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;

namespace Tasks;

public class C
{
    public static void Main()
    {
        using var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static void Solve()
    {
        var dp = new HashSet<long>();
        dp.Add(0);
        for (var i = 0; i < 3; i++)
        {
            var N = Scanner.Scan<int>();
            var A = Scanner.ScanEnumerable<long>().Distinct().ToArray();
            var ndp = new HashSet<long>();
            foreach (var v in dp)
            {
                foreach (var a in A)
                {
                    ndp.Add(v + a);
                }
            }

            dp = ndp;
        }

        var Q = Scanner.Scan<int>();
        var X = Scanner.ScanEnumerable<long>().ToArray();
        foreach (var x in X)
        {
            var answer = dp.Contains(x);
            Console.WriteLine(answer ? "Yes" : "No");
        }
    }

    public static class Scanner
    {
        public static T Scan<T>() where T : IConvertible => Convert<T>(ScanStringArray()[0]);
        public static (T1, T2) Scan<T1, T2>() where T1 : IConvertible where T2 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]));
        }
        public static (T1, T2, T3) Scan<T1, T2, T3>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]));
        }
        public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]));
        }
        public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]));
        }
        public static (T1, T2, T3, T4, T5, T6) Scan<T1, T2, T3, T4, T5, T6>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible where T6 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]), Convert<T6>(input[5]));
        }
        public static IEnumerable<T> ScanEnumerable<T>() where T : IConvertible => ScanStringArray().Select(Convert<T>);
        private static string[] ScanStringArray()
        {
            var line = Console.ReadLine()?.Trim() ?? string.Empty;
            return string.IsNullOrEmpty(line) ? Array.Empty<string>() : line.Split(' ');
        }
        private static T Convert<T>(string value) where T : IConvertible => (T)System.Convert.ChangeType(value, typeof(T));
    }
}

Submission Info

Submission Time
Task C - A+B+C
User AconCavy
Language C# 11.0 (.NET 7.0.7)
Score 250
Code Size 3493 Byte
Status AC
Exec Time 201 ms
Memory 93616 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
Status
AC × 1
AC × 23
Set Name Test Cases
Sample sample_01.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt
Case Name Status Exec Time Memory
min.txt AC 52 ms 26404 KiB
random_01.txt AC 90 ms 46716 KiB
random_02.txt AC 67 ms 34416 KiB
random_03.txt AC 88 ms 47564 KiB
random_04.txt AC 167 ms 77020 KiB
random_05.txt AC 81 ms 44412 KiB
random_06.txt AC 71 ms 33112 KiB
random_07.txt AC 76 ms 42680 KiB
random_08.txt AC 149 ms 75976 KiB
random_09.txt AC 89 ms 45356 KiB
random_10.txt AC 98 ms 44636 KiB
random_11.txt AC 128 ms 61488 KiB
random_12.txt AC 201 ms 88052 KiB
random_13.txt AC 99 ms 46496 KiB
random_14.txt AC 159 ms 68500 KiB
random_15.txt AC 134 ms 60216 KiB
random_16.txt AC 166 ms 79760 KiB
random_17.txt AC 142 ms 89532 KiB
random_18.txt AC 160 ms 93352 KiB
random_19.txt AC 144 ms 91156 KiB
random_20.txt AC 143 ms 92400 KiB
random_21.txt AC 152 ms 93616 KiB
sample_01.txt AC 49 ms 26348 KiB