Submission #53858758


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    internal class Program
    {
        public static void Main(string[] args)
        {
            // 入力・宣言
            var line = Console.ReadLine().Split();
            int n = Convert.ToInt32(line[0]);
            int m = Convert.ToInt32(line[1]);
            var lineA = Console.ReadLine().Split();
            var lineB = Console.ReadLine().Split();
            int[] a = new int[n];
            int[] b = new int[m];
            for(int i = 0; i < n; ++i)
            {
                a[i] = Convert.ToInt32(lineA[i]);
            }
            for(int i = 0;i < m; ++i)
            {
                b[i] = Convert.ToInt32(lineB[i]);
            }
            int[] c = new int[n + m];
            for(int i = 0;i < n + m; ++i)
            {
                if(i < n)
                {
                    c[i] = a[i];
                }
                else
                {
                    c[i] = b[i - n];
                }
            }

            // 処理
            Array.Sort(a);
            Array.Sort(c);
            bool temp = false;
            bool success = false;
            int index = 0;
            for(int i = 0;i < c.Length; ++i)
            {
                if (temp)
                {
                    if (c[i] == a[index])
                    {
                        success = true;
                    }
                    else
                    {
                        temp = false;
                    }
                }
                if (c[i] == a[index])
                {
                    if (index < a.Length - 1)
                    {
                        index++;
                    }
                    temp = true;
                }
            }


            // 出力
            string ans = success ? "Yes" : "No";
            Console.WriteLine(ans);

        }
    }

Submission Info

Submission Time
Task B - Piano 2
User beef
Language C# 11.0 (.NET 7.0.7)
Score 200
Code Size 2055 Byte
Status AC
Exec Time 49 ms
Memory 24880 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 20
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt, 02_handmade_07.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 42 ms 24788 KiB
00_sample_02.txt AC 43 ms 24776 KiB
00_sample_03.txt AC 47 ms 24720 KiB
01_random_01.txt AC 34 ms 24732 KiB
01_random_02.txt AC 49 ms 24784 KiB
01_random_03.txt AC 41 ms 24624 KiB
01_random_04.txt AC 42 ms 24880 KiB
01_random_05.txt AC 41 ms 24708 KiB
01_random_06.txt AC 38 ms 24744 KiB
01_random_07.txt AC 38 ms 24784 KiB
01_random_08.txt AC 46 ms 24832 KiB
01_random_09.txt AC 43 ms 24736 KiB
01_random_10.txt AC 39 ms 24712 KiB
02_handmade_01.txt AC 38 ms 24844 KiB
02_handmade_02.txt AC 46 ms 24592 KiB
02_handmade_03.txt AC 40 ms 24632 KiB
02_handmade_04.txt AC 37 ms 24712 KiB
02_handmade_05.txt AC 46 ms 24688 KiB
02_handmade_06.txt AC 46 ms 24584 KiB
02_handmade_07.txt AC 31 ms 24704 KiB