結果
| 問題 | No.1438 Broken Drawers | 
| コンテスト | |
| ユーザー |  bluemegane | 
| 提出日時 | 2021-03-27 07:53:50 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 215 ms / 2,000 ms | 
| コード長 | 841 bytes | 
| コンパイル時間 | 1,689 ms | 
| コンパイル使用メモリ | 117,480 KB | 
| 実行使用メモリ | 53,664 KB | 
| 最終ジャッジ日時 | 2024-11-29 08:05:48 | 
| 合計ジャッジ時間 | 6,401 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
    }
}
            
            
            
        