結果

問題 No.390 最長の数列
ユーザー bluemeganebluemegane
提出日時 2021-04-30 12:38:27
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 969 ms
コンパイル使用メモリ 63,492 KB
実行使用メモリ 31,232 KB
最終ジャッジ日時 2023-09-25 13:26:29
合計ジャッジ時間 3,788 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,652 KB
testcase_01 AC 59 ms
20,780 KB
testcase_02 AC 60 ms
22,604 KB
testcase_03 AC 59 ms
22,604 KB
testcase_04 WA -
testcase_05 AC 124 ms
29,332 KB
testcase_06 AC 111 ms
31,200 KB
testcase_07 AC 58 ms
20,664 KB
testcase_08 AC 60 ms
21,984 KB
testcase_09 AC 64 ms
22,080 KB
testcase_10 WA -
testcase_11 AC 125 ms
29,304 KB
testcase_12 WA -
testcase_13 AC 106 ms
26,336 KB
testcase_14 AC 120 ms
27,128 KB
testcase_15 AC 57 ms
22,612 KB
testcase_16 AC 62 ms
22,024 KB
testcase_17 AC 72 ms
22,560 KB
testcase_18 AC 73 ms
22,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        var ans = 0;
        Array.Sort(a);
        var amax = a[n - 1];
        var b = new bool[amax + 1];
        var used = new bool[amax + 1];
        for (int i = 0; i < n; i++) b[a[i]] = true;
        for (int i = 0; i < n; i++)
        {
            if (used[a[i]]) continue;
            var p = a[i];
            var prep = 0;
            var count = 0;
            {
                while (p <= amax)
                {
                    if (b[p]) { count++; used[p] = true; prep = p;   p += p; }
                    else p += prep;
                }
            }
            ans = Max(ans, count);
        }
        Console.WriteLine(ans);
    }
}
0