結果

問題 No.318 学学学学学
ユーザー eitahoeitaho
提出日時 2015-12-11 01:11:40
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,927 bytes
コンパイル時間 2,351 ms
コンパイル使用メモリ 109,280 KB
実行使用メモリ 45,220 KB
最終ジャッジ日時 2023-10-13 10:45:35
合計ジャッジ時間 7,969 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 189 ms
45,220 KB
testcase_08 AC 182 ms
43,852 KB
testcase_09 AC 175 ms
41,212 KB
testcase_10 AC 165 ms
42,600 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 165 ms
41,168 KB
testcase_18 WA -
testcase_19 AC 171 ms
39,232 KB
testcase_20 WA -
testcase_21 AC 66 ms
23,712 KB
testcase_22 AC 67 ms
23,752 KB
testcase_23 AC 67 ms
23,696 KB
testcase_24 AC 67 ms
21,800 KB
testcase_25 AC 68 ms
23,740 KB
testcase_26 AC 68 ms
23,748 KB
testcase_27 AC 69 ms
23,756 KB
testcase_28 AC 67 ms
19,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        var sorted = A.Distinct().ToArray();
        Array.Sort(sorted);
        var id = A.Select(a => Array.BinarySearch(sorted, a)).ToArray();
        int[] L = Enu.Repeat(N, sorted.Length).ToArray();
        int[] R = Enu.Repeat(-1, sorted.Length).ToArray();

        for (int i = 0; i < N; i++)
        {
            int v = id[i];
            L[v] = Math.Min(L[v], i);
            R[v] = Math.Max(R[v], i);
        }
        int[] ans = new int[N];
        int LL = 0, RR = N - 1;
        for (int i = sorted.Length - 1; i >= 0; i--)
        {
            for (int x = L[i]; x <= Math.Min(R[i], RR); x++)
                ans[x] = sorted[i];
            for (int x = Math.Max(L[i], LL); x <= R[i]; x++)
                ans[x] = sorted[i];
            LL = Math.Max(LL, R[i] + 1);
            RR = Math.Min(RR, L[i] - 1);
        }

        Console.WriteLine(string.Join(" ", ans));
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    private static TextReader reader = Console.In;
    private static readonly char[] separator = { ' ' };
    private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    private static string[] A = new string[0];
    private static int i;
    private static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); }
    public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); }
    public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Next()).ToArray(); }
    public static string Line() { return reader.ReadLine().Trim(); }
    private static string[] Split(string s) { return s.Split(separator, op); }
    private static string Next() { CheckNext(); return A[i++]; }
    private static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}
0