Submission #32416252


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 E
    {
        public static void Main()
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, M) = Scanner.Scan<int, int>();
            var S = Scanner.ScanEnumerable<long>().ToArray();
            var X = Scanner.ScanEnumerable<long>().ToArray();

            var B = new long[N];
            for (var i = 0; i < N - 1; i++)
            {
                B[i + 1] = S[i] - B[i];
            }

            var dict = new Dictionary<long, long>();
            for (var i = 0; i < N; i++)
            {
                for (var j = 0; j < M; j++)
                {
                    var c = X[j] - B[i];
                    if (i % 2 == 1) c *= -1;
                    if (!dict.ContainsKey(c)) dict[c] = 0;
                    dict[c]++;
                }
            }

            var answer = dict.Values.Max();
            Console.WriteLine(answer);
        }

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

Submission Info

Submission Time
Task E - Lucky Numbers
User AconCavy
Language C# (.NET Core 3.1.201)
Score 500
Code Size 3572 Byte
Status AC
Exec Time 293 ms
Memory 103252 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 47
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 93 ms 27856 KiB
001.txt AC 147 ms 39808 KiB
002.txt AC 135 ms 41820 KiB
003.txt AC 134 ms 41684 KiB
004.txt AC 142 ms 40176 KiB
005.txt AC 283 ms 103252 KiB
006.txt AC 123 ms 48860 KiB
007.txt AC 139 ms 39032 KiB
008.txt AC 142 ms 42380 KiB
009.txt AC 166 ms 67416 KiB
010.txt AC 111 ms 38664 KiB
011.txt AC 111 ms 38732 KiB
012.txt AC 111 ms 38912 KiB
013.txt AC 105 ms 40172 KiB
014.txt AC 111 ms 38916 KiB
015.txt AC 258 ms 94544 KiB
016.txt AC 229 ms 69072 KiB
017.txt AC 202 ms 64712 KiB
018.txt AC 174 ms 51996 KiB
019.txt AC 146 ms 39076 KiB
020.txt AC 293 ms 99456 KiB
021.txt AC 278 ms 99344 KiB
022.txt AC 265 ms 99620 KiB
023.txt AC 278 ms 99368 KiB
024.txt AC 273 ms 99616 KiB
025.txt AC 104 ms 38076 KiB
026.txt AC 159 ms 62864 KiB
027.txt AC 128 ms 50460 KiB
028.txt AC 118 ms 45160 KiB
029.txt AC 121 ms 44672 KiB
030.txt AC 275 ms 99208 KiB
031.txt AC 275 ms 99048 KiB
032.txt AC 283 ms 99612 KiB
033.txt AC 272 ms 99340 KiB
034.txt AC 267 ms 99216 KiB
035.txt AC 134 ms 39888 KiB
036.txt AC 149 ms 40944 KiB
037.txt AC 161 ms 40216 KiB
038.txt AC 143 ms 44672 KiB
039.txt AC 145 ms 44460 KiB
040.txt AC 153 ms 44172 KiB
041.txt AC 161 ms 49400 KiB
042.txt AC 159 ms 44472 KiB
043.txt AC 161 ms 50644 KiB
044.txt AC 168 ms 60492 KiB
example0.txt AC 86 ms 28016 KiB
example1.txt AC 89 ms 28240 KiB