Submission #52887829


Source Code Expand

Copy
#include <iostream>
using namespace std;
const int N = 2e5 + 10;
int a[N];
int main() {
int n;
cin >> n;
for(int i = 1; i <= n; i++) cin>>a[i];
int b[N], cnt = 0;
for (int i = 1; i <= n; i++){
b[++cnt] = a[i];
while (cnt >= 2 && b[cnt] == b[cnt - 1]){
int x = b[cnt];
b [--cnt] = x + 1;
}
}
cout<<cnt<<"\n";
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <iostream>
using namespace std;
const int N = 2e5 + 10;
int a[N];
int main() {
	int n;
    cin >> n;
    for(int i = 1; i <= n; i++) cin>>a[i];
    int b[N], cnt = 0;
    for (int i = 1; i <= n; i++){
        b[++cnt] = a[i];
        while (cnt >= 2 && b[cnt] == b[cnt - 1]){
            int x = b[cnt];
            b [--cnt] = x + 1;
        }
    }
    cout<<cnt<<"\n";
}

Submission Info

Submission Time
Task C - Merge the balls
User danianmercado
Language C++ 17 (gcc 12.2)
Score 250
Code Size 401 Byte
Status AC
Exec Time 54 ms
Memory 5236 KB

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 2 ms 4268 KB
example_01.txt AC 2 ms 4312 KB
hand_00.txt AC 54 ms 5012 KB
hand_01.txt AC 36 ms 4832 KB
hand_02.txt AC 35 ms 4784 KB
hand_03.txt AC 33 ms 5044 KB
hand_04.txt AC 33 ms 5096 KB
hand_05.txt AC 34 ms 5012 KB
hand_06.txt AC 34 ms 5092 KB
hand_07.txt AC 1 ms 4232 KB
hand_08.txt AC 1 ms 4316 KB
hand_09.txt AC 2 ms 4272 KB
hand_10.txt AC 1 ms 4272 KB
random_00.txt AC 51 ms 5236 KB
random_01.txt AC 49 ms 5080 KB
random_02.txt AC 50 ms 5160 KB
random_03.txt AC 50 ms 5192 KB
random_04.txt AC 51 ms 5192 KB
random_05.txt AC 50 ms 5192 KB
random_06.txt AC 50 ms 5048 KB
random_07.txt AC 50 ms 5096 KB
random_08.txt AC 50 ms 5096 KB
random_09.txt AC 50 ms 5196 KB
random_10.txt AC 51 ms 5032 KB
random_11.txt AC 51 ms 5036 KB
random_12.txt AC 50 ms 5044 KB
random_13.txt AC 51 ms 5156 KB
random_14.txt AC 51 ms 5092 KB
random_15.txt AC 50 ms 5096 KB
random_16.txt AC 50 ms 5036 KB
random_17.txt AC 50 ms 5156 KB
random_18.txt AC 50 ms 5048 KB
random_19.txt AC 50 ms 5012 KB
random_20.txt AC 51 ms 5196 KB
random_21.txt AC 50 ms 5096 KB
random_22.txt AC 50 ms 5096 KB
random_23.txt AC 50 ms 5076 KB
random_24.txt AC 49 ms 5092 KB


2025-03-17 (Mon)
21:59:55 +00:00