結果

問題 No.1438 Broken Drawers
ユーザー bluemeganebluemegane
提出日時 2021-03-27 07:53:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 297 ms / 2,000 ms
コード長 841 bytes
コンパイル時間 946 ms
コンパイル使用メモリ 65,920 KB
実行使用メモリ 49,796 KB
最終ジャッジ日時 2023-08-19 14:42:40
合計ジャッジ時間 7,010 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
21,564 KB
testcase_01 AC 55 ms
23,600 KB
testcase_02 AC 53 ms
23,560 KB
testcase_03 AC 57 ms
21,548 KB
testcase_04 AC 54 ms
21,636 KB
testcase_05 AC 53 ms
21,548 KB
testcase_06 AC 189 ms
45,496 KB
testcase_07 AC 233 ms
47,424 KB
testcase_08 AC 62 ms
23,716 KB
testcase_09 AC 60 ms
21,724 KB
testcase_10 AC 59 ms
21,728 KB
testcase_11 AC 66 ms
24,524 KB
testcase_12 AC 124 ms
37,400 KB
testcase_13 AC 154 ms
40,200 KB
testcase_14 AC 97 ms
27,036 KB
testcase_15 AC 276 ms
45,680 KB
testcase_16 AC 223 ms
47,240 KB
testcase_17 AC 224 ms
46,428 KB
testcase_18 AC 235 ms
46,636 KB
testcase_19 AC 230 ms
46,768 KB
testcase_20 AC 244 ms
49,032 KB
testcase_21 AC 232 ms
48,444 KB
testcase_22 AC 236 ms
49,256 KB
testcase_23 AC 239 ms
45,508 KB
testcase_24 AC 297 ms
49,796 KB
testcase_25 AC 239 ms
47,544 KB
testcase_26 AC 240 ms
47,548 KB
testcase_27 AC 243 ms
47,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Linq;
using System;

public class P
{
    public int a { get; set; }
    public int id { get; set; }
}

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ps = new P[n];
        string[] line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++)
        {
            ps[i] = new P { a = int.Parse(line[i]), id = i };
        }
        getAns(n, ps);
    }
    static void getAns(int n, P[] ps)
    {
        var ng = new bool[n];
        ps = ps.OrderBy(x => x.a).ToArray();
        var count = 0;
        for (int i = 0; i < n; i++)
        {
            if (!ng[ps[i].id])
            {
                count++;
                if (ps[i].id != 0) ng[ps[i].id - 1] = true;
            }
        }
        Console.WriteLine(count);
    }
}
0