Submission #52852406


Source Code Expand

// #pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf (ll)1e18
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define fi first
#define se second
#define lll __int128
const int N = 1e6 + 5;
ll n, a[N], q[N], t;
void solve() {
	cin >> n;
	for (ll i = 1; i <= n; i++)
		cin >> a[i];
	for (ll i = 1; i <= n; i++) {
		q[++t] = a[i];
		while (t >= 2 && q[t] == q[t - 1]) {
			q[t - 1] = q[t] + 1;
			t--;
		}
		// for (ll i = 1; i <= t; i++)
		// 	cout << q[i] << " \n"[i == t];
	}
	cout << t << endl;
}
int main() {
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
	solve();
	return 0;
}

Submission Info

Submission Time
Task C - Merge the balls
User TopCloser
Language C++ 20 (gcc 12.2)
Score 250
Code Size 725 Byte
Status AC
Exec Time 15 ms
Memory 6696 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 3432 KiB
example_01.txt AC 1 ms 3504 KiB
hand_00.txt AC 12 ms 4968 KiB
hand_01.txt AC 9 ms 4472 KiB
hand_02.txt AC 9 ms 4480 KiB
hand_03.txt AC 10 ms 6696 KiB
hand_04.txt AC 10 ms 6696 KiB
hand_05.txt AC 10 ms 5032 KiB
hand_06.txt AC 10 ms 6696 KiB
hand_07.txt AC 1 ms 3572 KiB
hand_08.txt AC 1 ms 3632 KiB
hand_09.txt AC 1 ms 3432 KiB
hand_10.txt AC 1 ms 3368 KiB
random_00.txt AC 13 ms 5892 KiB
random_01.txt AC 13 ms 5876 KiB
random_02.txt AC 15 ms 5880 KiB
random_03.txt AC 13 ms 5952 KiB
random_04.txt AC 13 ms 5804 KiB
random_05.txt AC 13 ms 6136 KiB
random_06.txt AC 13 ms 6216 KiB
random_07.txt AC 13 ms 6216 KiB
random_08.txt AC 12 ms 6536 KiB
random_09.txt AC 12 ms 6416 KiB
random_10.txt AC 13 ms 5724 KiB
random_11.txt AC 13 ms 5724 KiB
random_12.txt AC 13 ms 6264 KiB
random_13.txt AC 13 ms 6244 KiB
random_14.txt AC 12 ms 6156 KiB
random_15.txt AC 12 ms 6580 KiB
random_16.txt AC 12 ms 6288 KiB
random_17.txt AC 13 ms 6360 KiB
random_18.txt AC 12 ms 6604 KiB
random_19.txt AC 12 ms 6476 KiB
random_20.txt AC 14 ms 6532 KiB
random_21.txt AC 12 ms 6632 KiB
random_22.txt AC 13 ms 6628 KiB
random_23.txt AC 13 ms 6532 KiB
random_24.txt AC 12 ms 6632 KiB