結果

問題 No.3324 ハイライト動画
コンテスト
ユーザー 鳩でもわかるC#
提出日時 2025-11-01 15:22:24
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 479 ms / 2,000 ms
コード長 2,586 bytes
コンパイル時間 7,893 ms
コンパイル使用メモリ 169,040 KB
実行使用メモリ 188,060 KB
最終ジャッジ日時 2025-11-01 15:22:38
合計ジャッジ時間 14,079 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (107 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System.Diagnostics;
class Program
{
    static string ReadLine() => Console.ReadLine().Trim();
    static int ReadInt() => int.Parse(ReadLine());
    static long ReadLong() => long.Parse(ReadLine());
    static int[] ReadIntArray() { string str = ReadLine(); return str != "" ? str.Split().Select(_ => int.Parse(_)).ToArray() : new int[0]; }
    static long[] ReadLongArray() { string str = ReadLine(); return str != "" ? str.Split().Select(_ => long.Parse(_)).ToArray() : new long[0]; }

    static (int a, int b) ReadInt2() { int[] vs = ReadIntArray(); return (a: vs[0], b: vs[1]); }
    static (int a, int b, int c) ReadInt3() { int[] vs = ReadIntArray(); return (a: vs[0], b: vs[1], c: vs[2]); }
    static (int a, int b, int c, int d) ReadInt4() { int[] vs = ReadIntArray(); return (a: vs[0], b: vs[1], c: vs[2], d: vs[3]); }
    static (long a, long b) ReadLong2() { long[] vs = ReadLongArray(); return (a: vs[0], b: vs[1]); }
    static (long a, long b, long c) ReadLong3() { long[] vs = ReadLongArray(); return (a: vs[0], b: vs[1], c: vs[2]); }
    static (long a, long b, long c, long d) ReadLong4() { long[] vs = ReadLongArray(); return (a: vs[0], b: vs[1], c: vs[2], d: vs[3]); }

    class Pair
    {
        public Pair(int v)
        {
            V = v;
            Prev = v;
            C = 1;
        }
        public int V = 0;
        public int Prev = 0;
        public int C = 0;
    }

    static void Main()
    {
        SourceExpander.Expander.Expand();

        (int N, int M) = ReadInt2();
        int[] A = ReadIntArray();

        Stack<Pair> stack = new Stack<Pair>();
        foreach (int v in A)
        {
            if (stack.Count == 0)
                stack.Push(new Pair(v));
            else
            {
                if (v - stack.Peek().Prev == 1)
                {
                    stack.Peek().Prev = v;
                    stack.Peek().C++;
                }
                else
                    stack.Push(new Pair(v));
            }
        }
        Pair[] arr = stack.Reverse().ToArray();

        Console.WriteLine(arr.Length);
        foreach (Pair pair in arr)
            Console.WriteLine($"{pair.V} {pair.C}");
    }
}

#region Expanded by https://github.com/kzrnm/SourceExpander
namespace SourceExpander{public class Expander{[Conditional("EXP")]public static void Expand(string inputFilePath=null,string outputFilePath=null,bool ignoreAnyError=true){}public static string ExpandString(string inputFilePath=null,bool ignoreAnyError=true){return "";}}}
#endregion Expanded by https://github.com/kzrnm/SourceExpander
0