7510 | 2024-01-09 11:55:40 | renn | Bob Baba Zárójelsorozata | cpp17 | Wrong answer 0/100 | 3ms | 5392 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) ? s : "-1") << "\n";
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1976 KiB | ||||
2 | Wrong answer | 3ms | 2008 KiB | ||||
3 | Accepted | 3ms | 2348 KiB | ||||
subtask2 | 0/20 | ||||||
4 | Accepted | 2ms | 2436 KiB | ||||
5 | Accepted | 3ms | 2540 KiB | ||||
6 | Wrong answer | 3ms | 2940 KiB | ||||
subtask3 | 0/30 | ||||||
7 | Wrong answer | 3ms | 2856 KiB | ||||
8 | Wrong answer | 3ms | 2936 KiB | ||||
9 | Wrong answer | 3ms | 3080 KiB | ||||
10 | Accepted | 3ms | 3164 KiB | ||||
11 | Wrong answer | 3ms | 3356 KiB | ||||
subtask4 | 0/50 | ||||||
12 | Accepted | 3ms | 3572 KiB | ||||
13 | Wrong answer | 3ms | 4032 KiB | ||||
14 | Wrong answer | 3ms | 4228 KiB | ||||
15 | Wrong answer | 3ms | 4248 KiB | ||||
16 | Accepted | 3ms | 4248 KiB | ||||
17 | Accepted | 3ms | 4012 KiB | ||||
18 | Accepted | 3ms | 4136 KiB | ||||
19 | Wrong answer | 3ms | 4244 KiB | ||||
20 | Wrong answer | 3ms | 4292 KiB | ||||
21 | Wrong answer | 3ms | 4272 KiB | ||||
22 | Accepted | 3ms | 4512 KiB | ||||
23 | Accepted | 3ms | 4492 KiB | ||||
24 | Accepted | 3ms | 4584 KiB | ||||
25 | Wrong answer | 3ms | 4960 KiB | ||||
26 | Wrong answer | 3ms | 4744 KiB | ||||
27 | Accepted | 3ms | 4716 KiB | ||||
28 | Accepted | 3ms | 4712 KiB | ||||
29 | Accepted | 3ms | 4708 KiB | ||||
30 | Accepted | 3ms | 4728 KiB | ||||
31 | Wrong answer | 3ms | 4820 KiB | ||||
32 | Wrong answer | 3ms | 4912 KiB | ||||
33 | Accepted | 3ms | 4916 KiB | ||||
34 | Accepted | 3ms | 4816 KiB | ||||
35 | Accepted | 3ms | 4820 KiB | ||||
36 | Wrong answer | 3ms | 4812 KiB | ||||
37 | Wrong answer | 3ms | 4816 KiB | ||||
38 | Wrong answer | 3ms | 4936 KiB | ||||
39 | Wrong answer | 3ms | 4908 KiB | ||||
40 | Wrong answer | 3ms | 4940 KiB | ||||
41 | Wrong answer | 3ms | 5256 KiB | ||||
42 | Wrong answer | 3ms | 5016 KiB | ||||
43 | Wrong answer | 3ms | 5016 KiB | ||||
44 | Wrong answer | 3ms | 5012 KiB | ||||
45 | Wrong answer | 3ms | 5160 KiB | ||||
46 | Wrong answer | 3ms | 5124 KiB | ||||
47 | Wrong answer | 3ms | 5220 KiB | ||||
48 | Wrong answer | 3ms | 5124 KiB | ||||
49 | Wrong answer | 3ms | 5012 KiB | ||||
50 | Wrong answer | 3ms | 5140 KiB | ||||
51 | Wrong answer | 3ms | 5160 KiB | ||||
52 | Wrong answer | 3ms | 5160 KiB | ||||
53 | Wrong answer | 3ms | 5160 KiB | ||||
54 | Wrong answer | 3ms | 5160 KiB | ||||
55 | Wrong answer | 3ms | 5220 KiB | ||||
56 | Wrong answer | 3ms | 5388 KiB | ||||
57 | Wrong answer | 3ms | 5208 KiB | ||||
58 | Wrong answer | 3ms | 5392 KiB |