結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
23,604 KB
testcase_01 AC 55 ms
21,624 KB
testcase_02 AC 56 ms
21,616 KB
testcase_03 AC 55 ms
21,472 KB
testcase_04 AC 54 ms
23,712 KB
testcase_05 AC 53 ms
21,572 KB
testcase_06 AC 188 ms
49,180 KB
testcase_07 AC 229 ms
49,252 KB
testcase_08 AC 60 ms
23,792 KB
testcase_09 AC 61 ms
23,864 KB
testcase_10 AC 61 ms
19,584 KB
testcase_11 AC 73 ms
22,424 KB
testcase_12 AC 124 ms
37,452 KB
testcase_13 AC 154 ms
38,352 KB
testcase_14 AC 97 ms
27,120 KB
testcase_15 AC 225 ms
47,240 KB
testcase_16 AC 225 ms
48,656 KB
testcase_17 AC 234 ms
49,840 KB
testcase_18 AC 236 ms
50,144 KB
testcase_19 AC 233 ms
50,432 KB
testcase_20 AC 237 ms
50,776 KB
testcase_21 AC 228 ms
48,028 KB
testcase_22 AC 236 ms
48,752 KB
testcase_23 AC 242 ms
51,220 KB
testcase_24 AC 243 ms
49,152 KB
testcase_25 AC 236 ms
51,108 KB
testcase_26 AC 234 ms
51,280 KB
testcase_27 AC 236 ms
51,136 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];
        var ok = new bool[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 };
            ok[i] = true;
        }
        getAns(n, ps, ok);
    }
    static void getAns(int n, P[] ps, bool[] ok)
    {
        ps = ps.OrderBy(x => x.a).ToArray();
        var count = 0;
        for (int i = 0; i < n; i++)
        {
            if (ok[ps[i].id])
            {
                count++;
                if (ps[i].id != 0) ok[ps[i].id - 1] = false;
            }
        }
        Console.WriteLine(count);
    }
}
0