結果

問題 No.1338 Giant Class
ユーザー bluemegane
提出日時 2021-01-16 09:07:27
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 959 bytes
コンパイル時間 947 ms
コンパイル使用メモリ 105,600 KB
実行使用メモリ 34,176 KB
最終ジャッジ日時 2024-11-27 08:42:14
合計ジャッジ時間 4,837 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Text;
using System.Collections.Generic;
using System;

public class Hello
{
    public static long h, w;
    public static int q;
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        h = long.Parse(line[0]);
        w = long.Parse(line[1]);
        q = int.Parse(line[2]);
        getAns();
    }
    static void getAns()
    {
        var sb = new StringBuilder();
        var ans = h * w;
        var dw = new Dictionary<int, int>();
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var x = int.Parse(line[0]) - 1;
            var y = int.Parse(line[1]) - 1;
            if (dw.ContainsKey(y))
            {
                if (x < dw[y]) { ans -= dw[y] - x; dw[y] = x; }
            }
            else { ans -= h - x; dw[y] = x; }
            sb.Append(ans.ToString() + "\n");
        }
        Console.Write(sb);
    }
}
0