Submission #52876969


Source Code Expand

using System;
using System.Collections.Generic;

class Program{
  
  public static void Main(string[] args){
    
    int n = Convert.ToInt32(Console.ReadLine());
    
    var line = Console.ReadLine().Split();
    int[] a = new int[n];
    Stack<int> resultStack = new Stack<int>();
    for(int i = 0;i < n; ++i){
       a[i] = Convert.ToInt32(line[i]);
    }
    
    // 処理
    resultStack.Push(a[0]);
    for(int i = 1;i < n; ++i){
      int temp = a[i];
      while(resultStack.Count != 0 && resultStack.Peek() == temp){
        temp  = resultStack.Pop() + 1;
      }
      resultStack.Push(temp);
    }
    
    // 出力
    Console.WriteLine(resultStack.Count);  
  }
  
}

Submission Info

Submission Time
Task C - Merge the balls
User beef
Language C# 11.0 (.NET 7.0.7)
Score 250
Code Size 713 Byte
Status AC
Exec Time 69 ms
Memory 44304 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
Status
AC × 2
AC × 38
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 45 ms 24920 KiB
example_01.txt AC 42 ms 25188 KiB
hand_00.txt AC 69 ms 44304 KiB
hand_01.txt AC 57 ms 37388 KiB
hand_02.txt AC 53 ms 37420 KiB
hand_03.txt AC 55 ms 41224 KiB
hand_04.txt AC 56 ms 41340 KiB
hand_05.txt AC 56 ms 39424 KiB
hand_06.txt AC 64 ms 41180 KiB
hand_07.txt AC 30 ms 24936 KiB
hand_08.txt AC 38 ms 25012 KiB
hand_09.txt AC 38 ms 24960 KiB
hand_10.txt AC 38 ms 24832 KiB
random_00.txt AC 61 ms 42596 KiB
random_01.txt AC 63 ms 42688 KiB
random_02.txt AC 64 ms 42556 KiB
random_03.txt AC 63 ms 42544 KiB
random_04.txt AC 55 ms 42848 KiB
random_05.txt AC 59 ms 43580 KiB
random_06.txt AC 67 ms 43412 KiB
random_07.txt AC 64 ms 43252 KiB
random_08.txt AC 59 ms 43380 KiB
random_09.txt AC 56 ms 43620 KiB
random_10.txt AC 59 ms 42616 KiB
random_11.txt AC 60 ms 42436 KiB
random_12.txt AC 62 ms 43304 KiB
random_13.txt AC 58 ms 43568 KiB
random_14.txt AC 66 ms 43300 KiB
random_15.txt AC 58 ms 43616 KiB
random_16.txt AC 57 ms 43448 KiB
random_17.txt AC 63 ms 43588 KiB
random_18.txt AC 61 ms 43432 KiB
random_19.txt AC 62 ms 43688 KiB
random_20.txt AC 67 ms 43492 KiB
random_21.txt AC 55 ms 43700 KiB
random_22.txt AC 64 ms 43472 KiB
random_23.txt AC 55 ms 43456 KiB
random_24.txt AC 62 ms 43456 KiB