Submission #52855592


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace atcoder;
namespace mp = boost::multiprecision;

using ll = long long;
using pll = pair<ll,ll>;
using bint = mp::cpp_int;

int main()
{
  stack<ll> S;
  ll N;
  cin >> N;
  for(ll i = 0;i < N;i++)
  {
    ll A;
    cin >> A;
    S.push(A);
    while(S.size()>=2)
    {
      ll s1 = S.top();
      S.pop();
      ll s2 = S.top();
      S.pop();
      if(s1==s2)
      {
        ll s3 = s1+1;
        S.push(s3);
      }
      else
      {
        S.push(s2);
        S.push(s1);
        break;
      }
    }
  }
  cout << S.size() << endl;
  return 0;
}

Submission Info

Submission Time
Task C - Merge the balls
User n0dasalt
Language C++ 20 (gcc 12.2)
Score 250
Code Size 725 Byte
Status AC
Exec Time 55 ms
Memory 5276 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 1 ms 3560 KiB
example_01.txt AC 1 ms 3468 KiB
hand_00.txt AC 55 ms 3568 KiB
hand_01.txt AC 37 ms 3472 KiB
hand_02.txt AC 36 ms 3500 KiB
hand_03.txt AC 34 ms 5168 KiB
hand_04.txt AC 34 ms 5164 KiB
hand_05.txt AC 33 ms 3632 KiB
hand_06.txt AC 35 ms 5144 KiB
hand_07.txt AC 1 ms 3500 KiB
hand_08.txt AC 1 ms 3568 KiB
hand_09.txt AC 1 ms 3496 KiB
hand_10.txt AC 1 ms 3640 KiB
random_00.txt AC 50 ms 4368 KiB
random_01.txt AC 51 ms 4352 KiB
random_02.txt AC 51 ms 4420 KiB
random_03.txt AC 51 ms 4416 KiB
random_04.txt AC 50 ms 4492 KiB
random_05.txt AC 50 ms 4940 KiB
random_06.txt AC 50 ms 4732 KiB
random_07.txt AC 50 ms 4912 KiB
random_08.txt AC 50 ms 5184 KiB
random_09.txt AC 50 ms 4980 KiB
random_10.txt AC 50 ms 4244 KiB
random_11.txt AC 51 ms 4196 KiB
random_12.txt AC 50 ms 4884 KiB
random_13.txt AC 50 ms 4776 KiB
random_14.txt AC 50 ms 4820 KiB
random_15.txt AC 49 ms 4900 KiB
random_16.txt AC 50 ms 4900 KiB
random_17.txt AC 50 ms 4936 KiB
random_18.txt AC 50 ms 5128 KiB
random_19.txt AC 50 ms 5148 KiB
random_20.txt AC 50 ms 5160 KiB
random_21.txt AC 49 ms 5276 KiB
random_22.txt AC 50 ms 5212 KiB
random_23.txt AC 50 ms 5208 KiB
random_24.txt AC 50 ms 5148 KiB