79032024-01-11 19:39:20AblablablaTáblajáték 2 (70 pont)cpp17Partially correct 49/703ms3684 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";
    cout << harmas(elem) << "\n";
}
SubtaskSumTestVerdictTimeMemory
base49/70
1Accepted0/03ms1808 KiB
2Accepted0/03ms2012 KiB
3Accepted2/23ms2248 KiB
4Accepted3/33ms2448 KiB
5Accepted3/33ms2580 KiB
6Partially correct1/33ms2720 KiB
7Accepted3/33ms2744 KiB
8Accepted3/33ms2896 KiB
9Accepted3/33ms3008 KiB
10Accepted3/33ms3256 KiB
11Accepted3/33ms3340 KiB
12Partially correct1/33ms3256 KiB
13Accepted3/33ms3352 KiB
14Accepted3/33ms3332 KiB
15Accepted4/43ms3332 KiB
16Partially correct1/43ms3344 KiB
17Accepted4/43ms3412 KiB
18Accepted4/43ms3488 KiB
19Partially correct1/43ms3484 KiB
20Partially correct1/43ms3608 KiB
21Partially correct1/43ms3612 KiB
22Partially correct1/42ms3564 KiB
23Partially correct1/33ms3684 KiB