79042024-01-11 19:43:18AblablablaTáblajáték 2 (70 pont)cpp17Partially correct 51/703ms3364 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

string harmas(ll a){
    string vissza;
    while(a > 0){
        vissza += '0' + a % 3;
        a /= 3;
    }

    reverse(vissza.begin(), vissza.end());
    return vissza;
}

int main()
{
    int k;
    cin >> k;

    int sor = 0;
    ll elem = 0;

    for(int i = 0; i < k; i++){
        int a;
        cin >> a;

        if(a < 3){
            elem = elem * 3 + a;
            sor++;
        } else if(a == 3){
            sor--;
            elem /= 3;
        } else if(a == 4){
            elem--;
        } else{
            elem++;
        }
    }

    cout << sor << "\n";
    if(elem == 0){
        cout << "0\n";
    } else{
        cout << harmas(elem) << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base51/70
1Accepted0/03ms1960 KiB
2Accepted0/03ms2012 KiB
3Accepted2/23ms2256 KiB
4Accepted3/33ms2432 KiB
5Accepted3/33ms2648 KiB
6Partially correct1/32ms2656 KiB
7Accepted3/33ms2652 KiB
8Accepted3/33ms2772 KiB
9Accepted3/32ms2768 KiB
10Accepted3/33ms2896 KiB
11Accepted3/33ms3112 KiB
12Partially correct1/33ms3100 KiB
13Accepted3/32ms3080 KiB
14Accepted3/32ms3084 KiB
15Accepted4/42ms3084 KiB
16Partially correct1/42ms3084 KiB
17Accepted4/43ms3108 KiB
18Accepted4/43ms3320 KiB
19Partially correct1/43ms3356 KiB
20Partially correct1/43ms3244 KiB
21Partially correct1/42ms3244 KiB
22Partially correct1/43ms3248 KiB
23Accepted3/32ms3364 KiB