7513 | 2024-01-09 12:03:27 | renn | Bob Baba Zárójelsorozata | cpp17 | Wrong answer 0/100 | 3ms | 5260 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1828 KiB | ||||
2 | Wrong answer | 3ms | 2172 KiB | ||||
3 | Wrong answer | 3ms | 2240 KiB | ||||
subtask2 | 0/20 | ||||||
4 | Wrong answer | 3ms | 2328 KiB | ||||
5 | Wrong answer | 3ms | 2520 KiB | ||||
6 | Wrong answer | 3ms | 2756 KiB | ||||
subtask3 | 0/30 | ||||||
7 | Wrong answer | 3ms | 2868 KiB | ||||
8 | Wrong answer | 3ms | 2952 KiB | ||||
9 | Wrong answer | 3ms | 3100 KiB | ||||
10 | Wrong answer | 3ms | 3072 KiB | ||||
11 | Wrong answer | 3ms | 3196 KiB | ||||
subtask4 | 0/50 | ||||||
12 | Wrong answer | 3ms | 3288 KiB | ||||
13 | Wrong answer | 3ms | 3528 KiB | ||||
14 | Wrong answer | 3ms | 3496 KiB | ||||
15 | Wrong answer | 3ms | 3528 KiB | ||||
16 | Wrong answer | 3ms | 3596 KiB | ||||
17 | Wrong answer | 3ms | 3456 KiB | ||||
18 | Wrong answer | 3ms | 3572 KiB | ||||
19 | Wrong answer | 3ms | 3676 KiB | ||||
20 | Wrong answer | 3ms | 3656 KiB | ||||
21 | Wrong answer | 3ms | 3660 KiB | ||||
22 | Wrong answer | 3ms | 3792 KiB | ||||
23 | Wrong answer | 3ms | 3864 KiB | ||||
24 | Wrong answer | 3ms | 3964 KiB | ||||
25 | Wrong answer | 3ms | 3964 KiB | ||||
26 | Wrong answer | 3ms | 3968 KiB | ||||
27 | Wrong answer | 3ms | 4092 KiB | ||||
28 | Wrong answer | 3ms | 4308 KiB | ||||
29 | Wrong answer | 3ms | 4424 KiB | ||||
30 | Wrong answer | 3ms | 4276 KiB | ||||
31 | Wrong answer | 3ms | 4272 KiB | ||||
32 | Wrong answer | 3ms | 4376 KiB | ||||
33 | Wrong answer | 2ms | 4276 KiB | ||||
34 | Wrong answer | 2ms | 4280 KiB | ||||
35 | Wrong answer | 3ms | 4684 KiB | ||||
36 | Wrong answer | 3ms | 4572 KiB | ||||
37 | Wrong answer | 3ms | 4684 KiB | ||||
38 | Wrong answer | 3ms | 4544 KiB | ||||
39 | Wrong answer | 3ms | 4536 KiB | ||||
40 | Wrong answer | 3ms | 4772 KiB | ||||
41 | Wrong answer | 3ms | 5084 KiB | ||||
42 | Wrong answer | 3ms | 4744 KiB | ||||
43 | Wrong answer | 3ms | 4740 KiB | ||||
44 | Wrong answer | 3ms | 4740 KiB | ||||
45 | Wrong answer | 3ms | 4740 KiB | ||||
46 | Wrong answer | 3ms | 4892 KiB | ||||
47 | Wrong answer | 3ms | 4740 KiB | ||||
48 | Wrong answer | 3ms | 4888 KiB | ||||
49 | Wrong answer | 3ms | 4864 KiB | ||||
50 | Wrong answer | 3ms | 4988 KiB | ||||
51 | Wrong answer | 3ms | 5076 KiB | ||||
52 | Wrong answer | 3ms | 5056 KiB | ||||
53 | Wrong answer | 3ms | 5052 KiB | ||||
54 | Wrong answer | 3ms | 4956 KiB | ||||
55 | Wrong answer | 3ms | 5164 KiB | ||||
56 | Wrong answer | 3ms | 5048 KiB | ||||
57 | Wrong answer | 3ms | 5012 KiB | ||||
58 | Wrong answer | 3ms | 5260 KiB |