7511 | 2024-01-09 11:59:06 | renn | Bob Baba Zárójelsorozata | cpp17 | Wrong answer 20/100 | 3ms | 4724 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 | 1832 KiB | ||||
2 | Accepted | 3ms | 2172 KiB | ||||
3 | Accepted | 3ms | 2392 KiB | ||||
subtask2 | 20/20 | ||||||
4 | Accepted | 3ms | 2428 KiB | ||||
5 | Accepted | 3ms | 2804 KiB | ||||
6 | Accepted | 3ms | 3044 KiB | ||||
subtask3 | 0/30 | ||||||
7 | Wrong answer | 3ms | 3220 KiB | ||||
8 | Wrong answer | 3ms | 3184 KiB | ||||
9 | Wrong answer | 3ms | 3188 KiB | ||||
10 | Accepted | 3ms | 3308 KiB | ||||
11 | Wrong answer | 3ms | 3396 KiB | ||||
subtask4 | 0/50 | ||||||
12 | Accepted | 3ms | 3400 KiB | ||||
13 | Wrong answer | 3ms | 3640 KiB | ||||
14 | Wrong answer | 3ms | 3500 KiB | ||||
15 | Wrong answer | 3ms | 3608 KiB | ||||
16 | Accepted | 3ms | 3752 KiB | ||||
17 | Accepted | 3ms | 3668 KiB | ||||
18 | Accepted | 3ms | 3868 KiB | ||||
19 | Wrong answer | 3ms | 3928 KiB | ||||
20 | Wrong answer | 3ms | 3912 KiB | ||||
21 | Wrong answer | 3ms | 3912 KiB | ||||
22 | Accepted | 3ms | 3960 KiB | ||||
23 | Accepted | 3ms | 4044 KiB | ||||
24 | Accepted | 2ms | 4128 KiB | ||||
25 | Wrong answer | 2ms | 4128 KiB | ||||
26 | Wrong answer | 3ms | 4132 KiB | ||||
27 | Accepted | 3ms | 4192 KiB | ||||
28 | Accepted | 3ms | 4292 KiB | ||||
29 | Accepted | 3ms | 4388 KiB | ||||
30 | Accepted | 3ms | 4188 KiB | ||||
31 | Wrong answer | 3ms | 4188 KiB | ||||
32 | Wrong answer | 3ms | 4192 KiB | ||||
33 | Accepted | 3ms | 4192 KiB | ||||
34 | Accepted | 3ms | 4192 KiB | ||||
35 | Accepted | 3ms | 4292 KiB | ||||
36 | Wrong answer | 3ms | 4480 KiB | ||||
37 | Wrong answer | 3ms | 4472 KiB | ||||
38 | Wrong answer | 3ms | 4452 KiB | ||||
39 | Wrong answer | 2ms | 4444 KiB | ||||
40 | Wrong answer | 2ms | 4448 KiB | ||||
41 | Wrong answer | 3ms | 4684 KiB | ||||
42 | Wrong answer | 3ms | 4448 KiB | ||||
43 | Wrong answer | 3ms | 4616 KiB | ||||
44 | Wrong answer | 3ms | 4472 KiB | ||||
45 | Wrong answer | 3ms | 4476 KiB | ||||
46 | Wrong answer | 3ms | 4484 KiB | ||||
47 | Wrong answer | 3ms | 4484 KiB | ||||
48 | Wrong answer | 3ms | 4480 KiB | ||||
49 | Wrong answer | 3ms | 4632 KiB | ||||
50 | Wrong answer | 3ms | 4484 KiB | ||||
51 | Wrong answer | 3ms | 4588 KiB | ||||
52 | Wrong answer | 3ms | 4488 KiB | ||||
53 | Wrong answer | 3ms | 4632 KiB | ||||
54 | Wrong answer | 3ms | 4604 KiB | ||||
55 | Wrong answer | 3ms | 4688 KiB | ||||
56 | Wrong answer | 3ms | 4580 KiB | ||||
57 | Wrong answer | 3ms | 4536 KiB | ||||
58 | Wrong answer | 3ms | 4724 KiB |