Submission #52854902


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
int main(){
long long N;
cin >> N;
vector<long long> A(N);
for(int i = 0;i < N;i++) cin >> A[i];
vector<long long> ans;
for(int i = 0;i < N;i++){
ans.push_back(A[i]);
long long siz,temp;
siz = ans.size();
if(siz==1) continue;
while(ans[siz-1] == ans[siz-2]){
temp = ans[siz-1];
ans.erase(ans.begin()+(siz-1));
siz--;
ans[siz-1] = temp+1;
if(siz==1) break;
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0;i < N;i++) cin >> A[i];
    vector<long long> ans;
    for(int i = 0;i < N;i++){
        ans.push_back(A[i]);
        long long siz,temp;
        siz = ans.size();
        if(siz==1) continue;
        while(ans[siz-1] == ans[siz-2]){
            temp = ans[siz-1];
            ans.erase(ans.begin()+(siz-1));
            siz--;
            ans[siz-1] = temp+1;
            if(siz==1) break;
        }
    }
    cout << ans.size() << endl;
}

Submission Info

Submission Time
Task C - Merge the balls
User miromaru360
Language C++ 20 (gcc 12.2)
Score 250
Code Size 596 Byte
Status AC
Exec Time 53 ms
Memory 6916 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 1 ms 3464 KB
example_01.txt AC 1 ms 3524 KB
hand_00.txt AC 53 ms 4636 KB
hand_01.txt AC 35 ms 4164 KB
hand_02.txt AC 35 ms 4092 KB
hand_03.txt AC 35 ms 6808 KB
hand_04.txt AC 34 ms 6772 KB
hand_05.txt AC 34 ms 4696 KB
hand_06.txt AC 35 ms 6856 KB
hand_07.txt AC 1 ms 3464 KB
hand_08.txt AC 1 ms 3496 KB
hand_09.txt AC 1 ms 3568 KB
hand_10.txt AC 1 ms 3460 KB
random_00.txt AC 50 ms 5756 KB
random_01.txt AC 50 ms 5760 KB
random_02.txt AC 51 ms 5676 KB
random_03.txt AC 50 ms 5764 KB
random_04.txt AC 51 ms 5724 KB
random_05.txt AC 50 ms 6856 KB
random_06.txt AC 51 ms 6760 KB
random_07.txt AC 50 ms 6832 KB
random_08.txt AC 50 ms 6688 KB
random_09.txt AC 51 ms 6716 KB
random_10.txt AC 50 ms 5728 KB
random_11.txt AC 52 ms 5652 KB
random_12.txt AC 50 ms 6684 KB
random_13.txt AC 51 ms 6828 KB
random_14.txt AC 50 ms 6716 KB
random_15.txt AC 50 ms 6824 KB
random_16.txt AC 52 ms 6688 KB
random_17.txt AC 51 ms 6828 KB
random_18.txt AC 50 ms 6800 KB
random_19.txt AC 50 ms 6680 KB
random_20.txt AC 51 ms 6796 KB
random_21.txt AC 50 ms 6712 KB
random_22.txt AC 50 ms 6820 KB
random_23.txt AC 50 ms 6916 KB
random_24.txt AC 50 ms 6760 KB


2025-03-28 (Fri)
13:01:31 +00:00