Submission #3271114


Source Code Expand

using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_005
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var d = new int[n, n];
            string[] input;
            for (int i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split(' ');
                for(int j = 0; j < n; j++)
                {
                    d[i, j] = int.Parse(input[j]);
                }
            }
            int q= int.Parse(Console.ReadLine());
            var p = new int[q];
            for(int i = 0; i < q; i++)
            {
                p[i] = int.Parse(Console.ReadLine());
            }

            //0からの距離に関するおいしさを計算
            var squareDel = new int[n, n];
            squareDel[0, 0] = d[0, 0];
            for(int i = 1; i < n; i++)
            {
                squareDel[i, 0] = squareDel[i - 1, 0] + d[i, 0];
                squareDel[0, i] = squareDel[0, i - 1] + d[0, i];
            }
            for(int i = 1; i < n; i++)
            {
                for(int j = 1; j < n; j++)
                {
                    squareDel[i, j] = d[i, j]
                        + squareDel[i - 1, j] + squareDel[i, j - 1]
                        - squareDel[i - 1, j - 1];
                }
            }

            for(int i = 0; i < n; i++)
            {
                string s = "";
                for(int j = 0; j < n; j++)
                {
                    s += squareDel[i, j].ToString() + " ";
                }
                Console.WriteLine(s);
            }

            var cntDel = new int[n * n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 1; k <= n - i; k++)
                    {
                        for (int l = 1; l <= n - j; l++)
                        {
                            int val = squareDel[i + k - 1, j + l - 1];
                            if (i > 0)
                            {
                                val -= squareDel[i - 1, j + l - 1];
                            }
                            if (j > 0)
                            {
                                val -= squareDel[i + k - 1, j - 1];
                            }
                            if (i > 0 && j > 0)
                            {
                                val += squareDel[i - 1, j - 1];
                            }
                            int square = k * l;
                            if (cntDel[square - 1] < val)
                            {
                                cntDel[square - 1] = val;
                            }
                        }
                    }
                }
            }

            for (int i = 1; i < n * n; i++)
            {
                if (cntDel[i] < cntDel[i - 1])
                {
                    cntDel[i] = cntDel[i - 1];
                }
            }


            for(int i = 0; i < q; i++)
            {
                Console.WriteLine(cntDel[p[i] - 1]);
            }
        }
    }
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User MiuraMiuMiu
Language C# (Mono 4.6.2.0)
Score 0
Code Size 3444 Byte
Status WA
Exec Time 58 ms
Memory 11164 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 0 / 50 0 / 50
Status
WA × 18
WA × 20
Set Name Test Cases
Subtask1 sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt
Subtask2 rand0.txt, rand1.txt, rand2.txt, rand3.txt, rand4.txt, rand_max0.txt, rand_max1.txt, rand_max2.txt, rand_max3.txt, rand_max4.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt
Case Name Status Exec Time Memory
rand0.txt WA 38 ms 9300 KB
rand1.txt WA 32 ms 11092 KB
rand2.txt WA 41 ms 9044 KB
rand3.txt WA 24 ms 9044 KB
rand4.txt WA 20 ms 9044 KB
rand_max0.txt WA 58 ms 9116 KB
rand_max1.txt WA 58 ms 9116 KB
rand_max2.txt WA 57 ms 11164 KB
rand_max3.txt WA 57 ms 9116 KB
rand_max4.txt WA 58 ms 11164 KB
s1.txt WA 22 ms 11092 KB
s2.txt WA 21 ms 11092 KB
sub0.txt WA 21 ms 9044 KB
sub1.txt WA 22 ms 11092 KB
sub2.txt WA 21 ms 9172 KB
sub_rand_max0.txt WA 22 ms 11092 KB
sub_rand_max1.txt WA 22 ms 11092 KB
sub_rand_max2.txt WA 21 ms 9044 KB
sub_rand_max3.txt WA 21 ms 11092 KB
sub_rand_min0.txt WA 20 ms 9044 KB