75132024-01-09 12:03:27rennBob Baba Zárójelsorozatacpp17Wrong answer 0/1003ms5260 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin >> n;

    vector<int> a(n);
    string s;

    for(auto &x : a)
        cin >> x;
    a.push_back(0);

    int nyit = 0, zar = 0;
    bool zarat_keres = false;

    for(int i = 0, j, k; i < n; i++)
    {
        nyit += a[i];
        zar = 0;
        for(j = i+1; j < n; j++)
        {
            zar += a[j];
            if(nyit == zar) // bezárható
            {
                for(k = 0; k < nyit; k++)
                    s += '(';
                for(k = 0; k < nyit; k++)
                    s += ')';
                i = j;
                nyit = 0;
                break;
            }

            if(nyit < zar) // túlmentem
                break;

            // még nem értem el, megyek tovább...
        }
    }
    cout << nyit << " " << zar << endl;

    cout << ((nyit <= zar) ? s : "-1") << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1828 KiB
2Wrong answer3ms2172 KiB
3Wrong answer3ms2240 KiB
subtask20/20
4Wrong answer3ms2328 KiB
5Wrong answer3ms2520 KiB
6Wrong answer3ms2756 KiB
subtask30/30
7Wrong answer3ms2868 KiB
8Wrong answer3ms2952 KiB
9Wrong answer3ms3100 KiB
10Wrong answer3ms3072 KiB
11Wrong answer3ms3196 KiB
subtask40/50
12Wrong answer3ms3288 KiB
13Wrong answer3ms3528 KiB
14Wrong answer3ms3496 KiB
15Wrong answer3ms3528 KiB
16Wrong answer3ms3596 KiB
17Wrong answer3ms3456 KiB
18Wrong answer3ms3572 KiB
19Wrong answer3ms3676 KiB
20Wrong answer3ms3656 KiB
21Wrong answer3ms3660 KiB
22Wrong answer3ms3792 KiB
23Wrong answer3ms3864 KiB
24Wrong answer3ms3964 KiB
25Wrong answer3ms3964 KiB
26Wrong answer3ms3968 KiB
27Wrong answer3ms4092 KiB
28Wrong answer3ms4308 KiB
29Wrong answer3ms4424 KiB
30Wrong answer3ms4276 KiB
31Wrong answer3ms4272 KiB
32Wrong answer3ms4376 KiB
33Wrong answer2ms4276 KiB
34Wrong answer2ms4280 KiB
35Wrong answer3ms4684 KiB
36Wrong answer3ms4572 KiB
37Wrong answer3ms4684 KiB
38Wrong answer3ms4544 KiB
39Wrong answer3ms4536 KiB
40Wrong answer3ms4772 KiB
41Wrong answer3ms5084 KiB
42Wrong answer3ms4744 KiB
43Wrong answer3ms4740 KiB
44Wrong answer3ms4740 KiB
45Wrong answer3ms4740 KiB
46Wrong answer3ms4892 KiB
47Wrong answer3ms4740 KiB
48Wrong answer3ms4888 KiB
49Wrong answer3ms4864 KiB
50Wrong answer3ms4988 KiB
51Wrong answer3ms5076 KiB
52Wrong answer3ms5056 KiB
53Wrong answer3ms5052 KiB
54Wrong answer3ms4956 KiB
55Wrong answer3ms5164 KiB
56Wrong answer3ms5048 KiB
57Wrong answer3ms5012 KiB
58Wrong answer3ms5260 KiB