7514 | 2024-01-09 12:04:38 | renn | Bob Baba Zárójelsorozata | cpp17 | Wrong answer 20/100 | 3ms | 5104 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 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2060 KiB | ||||
3 | Accepted | 3ms | 2280 KiB | ||||
subtask2 | 20/20 | ||||||
4 | Accepted | 3ms | 2500 KiB | ||||
5 | Accepted | 3ms | 2704 KiB | ||||
6 | Accepted | 3ms | 3076 KiB | ||||
subtask3 | 0/30 | ||||||
7 | Wrong answer | 2ms | 2960 KiB | ||||
8 | Wrong answer | 3ms | 2972 KiB | ||||
9 | Wrong answer | 2ms | 2964 KiB | ||||
10 | Accepted | 3ms | 2968 KiB | ||||
11 | Wrong answer | 3ms | 3080 KiB | ||||
subtask4 | 0/50 | ||||||
12 | Accepted | 3ms | 3308 KiB | ||||
13 | Wrong answer | 3ms | 3516 KiB | ||||
14 | Wrong answer | 3ms | 3632 KiB | ||||
15 | Wrong answer | 3ms | 4000 KiB | ||||
16 | Accepted | 3ms | 3904 KiB | ||||
17 | Accepted | 3ms | 3920 KiB | ||||
18 | Accepted | 3ms | 4128 KiB | ||||
19 | Wrong answer | 3ms | 4140 KiB | ||||
20 | Wrong answer | 3ms | 4128 KiB | ||||
21 | Wrong answer | 3ms | 4248 KiB | ||||
22 | Accepted | 3ms | 4256 KiB | ||||
23 | Accepted | 3ms | 4232 KiB | ||||
24 | Accepted | 2ms | 4232 KiB | ||||
25 | Wrong answer | 3ms | 4228 KiB | ||||
26 | Wrong answer | 3ms | 4360 KiB | ||||
27 | Accepted | 3ms | 4588 KiB | ||||
28 | Accepted | 3ms | 4596 KiB | ||||
29 | Accepted | 3ms | 4584 KiB | ||||
30 | Accepted | 3ms | 4588 KiB | ||||
31 | Wrong answer | 3ms | 4584 KiB | ||||
32 | Wrong answer | 3ms | 4580 KiB | ||||
33 | Accepted | 3ms | 4716 KiB | ||||
34 | Accepted | 2ms | 4796 KiB | ||||
35 | Accepted | 2ms | 4796 KiB | ||||
36 | Wrong answer | 2ms | 4796 KiB | ||||
37 | Wrong answer | 3ms | 4792 KiB | ||||
38 | Wrong answer | 3ms | 4792 KiB | ||||
39 | Wrong answer | 2ms | 4900 KiB | ||||
40 | Wrong answer | 2ms | 4896 KiB | ||||
41 | Wrong answer | 3ms | 5032 KiB | ||||
42 | Wrong answer | 2ms | 4796 KiB | ||||
43 | Wrong answer | 3ms | 4796 KiB | ||||
44 | Wrong answer | 2ms | 4940 KiB | ||||
45 | Wrong answer | 2ms | 4792 KiB | ||||
46 | Wrong answer | 3ms | 4796 KiB | ||||
47 | Wrong answer | 2ms | 4892 KiB | ||||
48 | Wrong answer | 3ms | 4800 KiB | ||||
49 | Wrong answer | 3ms | 4896 KiB | ||||
50 | Wrong answer | 3ms | 4996 KiB | ||||
51 | Wrong answer | 3ms | 4896 KiB | ||||
52 | Wrong answer | 3ms | 4956 KiB | ||||
53 | Wrong answer | 3ms | 4824 KiB | ||||
54 | Wrong answer | 3ms | 4804 KiB | ||||
55 | Wrong answer | 3ms | 5016 KiB | ||||
56 | Wrong answer | 3ms | 4956 KiB | ||||
57 | Wrong answer | 3ms | 5012 KiB | ||||
58 | Wrong answer | 3ms | 5104 KiB |