QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#162766#5246. Nawiasowe podziały [B]HMSF1 361ms41636kbC++143.5kb2023-09-03 16:25:462023-09-03 16:25:47

Judging History

你现在查看的是最新测评结果

  • [2023-09-03 16:25:47]
  • 评测
  • 测评结果:1
  • 用时:361ms
  • 内存:41636kb
  • [2023-09-03 16:25:46]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
//#include<set>
//#include<queue>
//#include<stack>
#define PII pair<int,int>
#define MP make_pair
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
inline LL read()
{
	LL s=0; bool w=0; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') w=1; ch=getchar();}
	while(ch>='0'&&ch<='9'){s=(s<<3)+(s<<1)+(ch^48); ch=getchar();}
	return w ? ~s+1 : s;
}

const int maxn = 400005;
const LL infl = 9223372036854775807;

struct Node
{
	int l,r;
	vector<int> son;
	vector<int> typ;
}tr[maxn];
int tot;

int n,m;
LL a[maxn];
char str[maxn];

void MakeNode(int l,int r,int fa,int x) { tr[x].l = l; tr[x].r = r; tr[fa].son.emplace_back(x); }

void Build(int l,int r,int x)
{
	if(l>=r) return;
	LL minn = infl;
	for(int i=l; i<=r; i++) minn = min(minn,a[i]);
	int lst = l;
	tr[x].son.emplace_back(0); tr[x].typ.emplace_back(0);
	for(int i=l; i<=r; i++)
	{
		if(a[i] == minn)
		{
			if(lst<=i-1) { MakeNode(lst,i-1,x,++tot); Build(lst,i-1,tot); tr[x].typ.emplace_back(0); }
			MakeNode(i,i,x,++tot); Build(i,i,tot); tr[x].typ.emplace_back(1); lst = i+1;
		}
		else if(i==r) { MakeNode(lst,i,x,++tot); Build(lst,i,tot); tr[x].typ.emplace_back(0); }
	}
	return;
}

struct DP1
{
	LL val;
	int num;
	DP1(){}; DP1(LL v_,int n_){val = v_; num = n_;}
}f[maxn],g[maxn];
LL h[maxn];
LL sum[maxn],pre[maxn];

int hd,tl;
struct DP2
{
	LL x,y;
	int num;
	DP2(){}; DP2(LL x_,LL y_,int n_){x=x_; y=y_; num=n_;}
}que[maxn<<2];

bool Convex(DP2 x,DP2 y,DP2 z) //如果三个点构成下凸壳返回true
{
	LL dif = (z.y-y.y)*(y.x-x.x) - (z.x-y.x)*(y.y-x.y);
	return dif==0 ? z.num < y.num : dif>0; //共线的话,保证选的边数是递减的
}
bool Tangent(DP2 x,DP2 y,LL tng){return (y.y-x.y) < (y.x-x.x)*tng;}

void Pop(LL tng){while(tl>hd && Tangent(que[hd],que[hd+1],tng)) hd++;}
void Push(DP2 t)
{
	while(tl>hd && !Convex(que[tl-1],que[tl],t)) tl--;
	que[++tl] = t; return;
}

void DP(int u,LL K)
{
	if(tr[u].l > tr[u].r) {f[u] = DP1(0,0); return;}
	if(tr[u].l == tr[u].r) {f[u] = DP1(-K,1); return;}
	int sz = tr[u].son.size()-1;
	for(int i=1; i<=sz; i++) DP(tr[u].son[i],K);
	for(int i=1; i<=sz; i++)
	{
		pre[i] = pre[i-1] + tr[u].typ[i];
		sum[i] = sum[i-1] + h[tr[u].son[i]];
	}
	hd = 1; tl = 0;
	Push(DP2(0,0,0));
	for(int i=1; i<=sz; i++)
	{
		Pop(pre[i]);
		g[i] = DP1(f[tr[u].son[i]].val + sum[i-1] + ((pre[i]-1)*pre[i])/2 +que[hd].y -pre[i]*que[hd].x,
				   f[tr[u].son[i]].num+que[hd].num);
		Push(DP2(pre[i-1],g[i].val-sum[i]+((pre[i-1]+1)*pre[i-1])/2,g[i].num));
	}
	LL tmp = 0;
	f[u].val = infl; f[u].num = 0;
	for(int i=sz; i>=1; i--)
	{
		g[i].val += tmp + ((pre[sz]-pre[i-1]-1)*(pre[sz]-pre[i-1]))/2;
		tmp += h[tr[u].son[i]];
		if(f[u].val > g[i].val || (f[u].val == g[i].val && f[u].num < g[i].num)) { f[u] = g[i]; }
	}
	h[u] = sum[sz] + ((pre[sz]-1)*pre[sz])/2; return;
}

int main()
{
	//freopen("input.txt","r",stdin);
	n = read(); m = read();
	scanf("%s",str+1);
	for(int i=1; i<=n; i++) a[i+1] = a[i] + (str[i] == '(' ? 1 : -1);
	n++;
	tr[++tot].l = 1; tr[1].r = n;
	Build(1,n,1);
	LL l = -1ll*n*n,r = 0;
	LL mid;
	while(l<r)
	{
		mid = (l+r)>>1;
		DP(1,mid); if(f[1].val > h[1]){f[1].val=h[1]; f[1].num=0;}
		if(f[1].num >= m-1) {r = mid;}
		else l = mid+1;
	}
	DP(1,l); if(f[1].val > h[1]) {f[1].val = h[1]; f[1].num = 0;}
	printf("%lld\n",f[1].val + l*(m-1));
	//fclose(stdin);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 1
Accepted
time: 8ms
memory: 32456kb

input:

1 1
(

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 9ms
memory: 32244kb

input:

1 1
)

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 33648kb

input:

2 1
()

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 1ms
memory: 32504kb

input:

2 1
)(

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 1ms
memory: 33524kb

input:

2 2
()

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 3ms
memory: 32776kb

input:

2 2
)(

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 1ms
memory: 33840kb

input:

10 4
()))(()(()

output:

0

result:

ok single line: '0'

Test #8:

score: -1
Wrong Answer
time: 0ms
memory: 33932kb

input:

15 4
())))()(()()(((

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'

Subtask #2:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 1ms
memory: 33888kb

input:

300 25
((()()()(()())(((())())()))()((()(())))((()()))((()()))()()(((())())))((((())(()()()())(((()))(()())()(())())()()()()())(()((()()()))))(())()((()))((()))(()(()())))((()(())(((()))))((()()()()()())())(((()))()()()(())())(())()(((()))()((()()())))((())())(((()())())((()))(()()()()(())(()())((()...

output:

87

result:

wrong answer 1st lines differ - expected: '90', found: '87'

Subtask #3:

score: 0
Wrong Answer

Test #33:

score: 1
Accepted
time: 4ms
memory: 33060kb

input:

4000 1
(((((())())()((())(())(()()())()())(()(())(()))()(()))(()((())()()()()(()())(()()()))()(())()()(()(()()())))(()))(()(((()))()())((())(()()(()()))))((()((()())())((())())((()()))(())(())(()(()()))(((())())())((())()()(()))(()()()(()(())(()))()())((()))((())()(())()())))(((()(()()()()())(())())...

output:

5599

result:

ok single line: '5599'

Test #34:

score: 0
Accepted
time: 3ms
memory: 32324kb

input:

4000 3
(((((((())))()()((((())(())()())()())(()(()())())))(()((())()((()()()((())()()))()))(())(()(()))()(()()()()((()(()))())()((()()()))(())(()()((())())))))(()(((((())))())((()()(((()()))())())())(())(()())(((()))())(()((()()()))(((()))())())())((())(())((())(())()(())()(((()))((())))))(((((())))...

output:

4568

result:

ok single line: '4568'

Test #35:

score: 0
Accepted
time: 6ms
memory: 32236kb

input:

4000 8
(((()))((()()(()())(()())((()))(((())))))(((())()(())()()()()((())())())((())()((())()))()(((())())()())(((()()()))(()()()(())(()))))(()()((()))((()())())((())(())()(())))(((((()()()())))(()()(()()())()()))()((())(()(()))((())()())((()()))()())(((())())()((()())(()()(())())()()((())))(())()((...

output:

4780

result:

ok single line: '4780'

Test #36:

score: -1
Wrong Answer
time: 5ms
memory: 32632kb

input:

4000 21
(((((()())(())()))(()(())((((())())))()((()))()(()())()((())()())()()((((()))))))(((((()())()()()))((()))())((()))(()()(()))(()()((())))(())((()()())())(()()(())))(((())(()((())))()()(())(()((()()())(()))(()))))((()()((()()()())()())(()((()()()())())))(()()(((())()())()()((())(()))()(()))()(...

output:

3863

result:

wrong answer 1st lines differ - expected: '3864', found: '3863'

Subtask #4:

score: 0
Wrong Answer

Test #54:

score: 1
Accepted
time: 5ms
memory: 33436kb

input:

4000 2
((())(()(())))()((())()()()(())()()(())()((()))()()((()()))((())())((())())(()())()(())(()(()))((()())())(()())((()()))(()()())((()))()())(()(()))((()()())(())()((())()))(())((())((())))(((()(())))()(())())(()(())(())())((())(())())((()(()))()()()()(()())())(((()))(())())((()())())((())()((()...

output:

18432

result:

ok single line: '18432'

Test #55:

score: 0
Accepted
time: 2ms
memory: 33840kb

input:

4000 5
(((((((()))(())(()(())()()(())(()))()()(((()))())()(()))(((()(()()))()())()()(()(())()(())))((()()()())(((())))((()())()(()()())()()()())()()(()(()))))())((()()())((((((()))()())(()())())())()((()()()(()()((()))()()())(())()())()()()))(())())()(((((()()(()(())()()))))((()()((())())((()())))((...

output:

4336

result:

ok single line: '4336'

Test #56:

score: 0
Accepted
time: 3ms
memory: 32204kb

input:

4000 13
(((((()()))(()()(()((())(()()()))(()))(((()()(()()))()())((())()())()())((()()(())())((()()()()))(())()(())())()((()(())())()()()()())((()(()()()(()())))(()()))(((())(()()))()(())))))()((())((((()()())(()()))(())((()((())))())()(((())()()(()()())(()))()(((()))(((())()()(())))))(((()())))(()(...

output:

3928

result:

ok single line: '3928'

Test #57:

score: -1
Wrong Answer
time: 10ms
memory: 32932kb

input:

4000 34
(((((()())()(((()())()(()(()))(())(((())))()))(()()(()(()(()))))((((()))))((()))(((()()(())))()()(())((()))))()(()(())()()((())))()(()((()))())()((())((((()(()))(()())()()(()(())(())))(()()()())))(()()))((()))((((()()))(((()))))))((((()))((()()())())()(((((())))()(())))())(((())))()((((())))...

output:

3282

result:

wrong answer 1st lines differ - expected: '3285', found: '3282'

Subtask #5:

score: 1
Accepted

Test #75:

score: 1
Accepted
time: 107ms
memory: 36696kb

input:

100000 3
(()((())(()))(())((()())))(((()()))(()))(()()()((())))()()((())(())((())(()(()))())((())))()()((())(()()))(((())))((())()(()())(()())()(()(()()())))(()(()()))()(()((())()()()()())((()))(())(())())(((()))()(()()())()(()()))((()()))(((()()()()))(()))(((())))(((()))(()()())(()(()()))(())(()())...

output:

3832013

result:

ok single line: '3832013'

Test #76:

score: 0
Accepted
time: 103ms
memory: 37004kb

input:

100000 9
(((((())(((())))(()))(()(()))((()()()))()(())(()))(((()()(()))))(()((()()))()(((()))((())))(())(()))(((()())(())((())))(()))()()(()((()))()(()(()())))((()(()))(()()((()())))((()(())())()((()))(()))()(()))((()((())))())(((()(())))()(((()())()()())(())()()(()(())(()())())))((()))(((()())()()(...

output:

131464

result:

ok single line: '131464'

Test #77:

score: 0
Accepted
time: 101ms
memory: 39680kb

input:

100000 15
()((()(()()))()(())(()))(((()))()((())(())(())(()())))(()()()())(()((())))()(((()))()(()(()))((()))(()))(()((())()()()(()))(())(())(()())(()()))(()(())(())(()()))(((())(())))(())(()()()()()()(()))((()()())())((()))(((())()()()))((())())()((())(())(())()()(()))((()()(()))()()()())()(()())((...

output:

1352858

result:

ok single line: '1352858'

Test #78:

score: 0
Accepted
time: 108ms
memory: 36620kb

input:

100000 21
((((())()(()()()((())))((())(())))((()()((((())()))()(()()()())()(()())(()(()))))(((()())(())()()((())))))()((()(()()())()(()()(()()((()))))))()(((((())())())((()())(())()()(())()()()))(()))()(((((()())()))((()()))))(((())(())())(()(())((()))))()((((()()())())))()(((())()()()(()(()()()))))...

output:

120911

result:

ok single line: '120911'

Test #79:

score: 0
Accepted
time: 103ms
memory: 39992kb

input:

100000 27
((()))(()(()))()(())((())())((())()(())())((())())()()(()()())(())(()(()())()(())(())(()()))((())()(()))(()(())()(()()))()(()(()(())()())()(()))((()())()(()())(((()))))((()))(())()((()()()())()(()()())((())())()()((())())(()()()))(()()(())())(()()(()()))(((()))(())()())(())()(()(()()()))((...

output:

1866778

result:

ok single line: '1866778'

Test #80:

score: 0
Accepted
time: 155ms
memory: 40720kb

input:

100000 1
)))))()))(()()()()((())(()()()))())())(()()()((()))()(())(((()))((())())()((((()))()()((()((()(()))())))(()))))()()())(()(())()))(()(()((()(())((((()((()())()))())())(((((((())())))(())))((()(())()(((((()()(()(()))(()))(())))()())()))))((()())))()))(()()))(((())(()(()()()(()))(((((((())()()...

output:

99830

result:

ok single line: '99830'

Test #81:

score: 0
Accepted
time: 152ms
memory: 39248kb

input:

100000 3
((((()(((()()))((())())))(()((()))()(()())(())((())())())()(((((()))()(())))(())(((()((((())())()((()(()(()))()))))()(()()))()))(())(()())())(()()))(()))())((())()(())())())())(()))((((()())(()))))())(()))(()(()())(()())()()())(((((()())())((((()(())()()()))(()(()()((())((())()(((()(()))(()...

output:

96717

result:

ok single line: '96717'

Test #82:

score: 0
Accepted
time: 150ms
memory: 40352kb

input:

100000 7
)((()((()(()(()())()))()))(((())))(()()))()))(())))))()()))()))))()))())(((()))(()(())(()())()))()(())(((((()())(()(())())))())((((()()(()(((((((()(()((((())()))()()())))))())())()((((())())(()(((()()(())((((((())(()()()))))())())))(((((()()()())(()(()(())((((())))()))))())())()))()(()((())...

output:

95714

result:

ok single line: '95714'

Test #83:

score: 0
Accepted
time: 155ms
memory: 40096kb

input:

99996 28
()())((()))()()())))()))))))(()(())()))(()((()())()()))()))()))))())((((()))(()))()()))(()()()((()))(())((()(())))(((())))()()())(((((()((((()(()))(((()(((((()))((((()((()(())()))(())(())()(()))((()())(((()()))))((()()(((()()))()())()()(()(())((()()(())((((())(())(()))()))()()))(()()(()())(...

output:

91255

result:

ok single line: '91255'

Test #84:

score: 0
Accepted
time: 155ms
memory: 37276kb

input:

100000 30
))(()()())))()())((())))())(((((()))()))()))(())()((()()))(((())))())()((((((()(((()())(())(()())()(())((()()()))(())(((())((()()()))(())))((())((())())))))()())())(()()))(()()()(()((((((()(()((())())())((((())()(())())((((())()())())((()))())()))))()()))()(()))(((())())((()()(())())()(()(...

output:

91102

result:

ok single line: '91102'

Test #85:

score: 0
Accepted
time: 361ms
memory: 41636kb

input:

99990 2
((())()()()()()()())(()())(())(()(())())((())())()((()(()))(()))(()())(()(()))((()()(()()))()()(())()(())(()())())()(()()(())(())(()))((()))(()()(())(())(()))(((())))(()()(())()((())(())))()(()()(()()))()((()))()()((())()())(()(()))(())(()(()))(((()))())(())(())(())((()))(()()())(()()()())()...

output:

94531

result:

ok single line: '94531'

Test #86:

score: 0
Accepted
time: 141ms
memory: 39384kb

input:

99998 5
((((())((((((())(()())(((()())(()))(()())((()())))))()(((()))(())((((())((()(())())((()))))))))((())(())(()))))))((()(()()())(((()()())(())())((((()))((())))(((((())()())(()))(((()))()))((()())))))))(((((((((((()())())(()()(((()()()))))))))(((()())))(((())()())((((()))))((()))))(((((())))()(...

output:

855997

result:

ok single line: '855997'

Test #87:

score: 0
Accepted
time: 151ms
memory: 39476kb

input:

100000 15
(())(()()(())()())()(())(())((()())())(((()))()()()()()()(())()()()())(()()()()()())()(()()())(())((()())()())(())()(()()(())(())()()()())(())()(())()(()())(())(()())()(()()()(())())()((()))()(()(()))()(()()()(())()()())((()))(()()()(()()))((())())(()()()()())((()()()))((())()(())()())(())...

output:

337304

result:

ok single line: '337304'

Test #88:

score: 0
Accepted
time: 284ms
memory: 41360kb

input:

99992 29
(((((((((()()())(((()))(())))((()((()))())))(((())(()()())())(())()))(((()(())())((()()))(((()())))))())((((((((((()((()()()))(()))(()()())((((())()())())))((((((()())()((()()(()))((())((()()))(((()()))))))(()())))(((((()((()()))())((()()))))(((((())(())(()))()))))((((((())((()))))))((((()(...

output:

285381

result:

ok single line: '285381'

Subtask #6:

score: 0
Wrong Answer

Test #89:

score: 1
Accepted
time: 114ms
memory: 37140kb

input:

100000 6
((((()()((())))()((()())()())((())()(((()()))())((())((()()()))()()()(())))(((()(())(()()))(())())(())))(((()))((((())))()))(()((())(())(())((()())))(()(()(()))(())(()()()(())())(()(())(()(()))(()())()((()))()()))(()()(())))((()())()((())((())()()(((()))(())))((())())()((()())(()))))()(((()...

output:

126039

result:

ok single line: '126039'

Test #90:

score: 0
Accepted
time: 103ms
memory: 39728kb

input:

100000 12
((()((())(((()))()())()()((()))())((((()()))()()))))(((())(()))(((((())))((())))(()()((()()()))((())()()((()(())((()))()()))())(()((()())())(()()(()))())()(()(())(())))()((()(()))((()))()((()()((())(())))))())(((()()))(()((()()))()(((()()()())()())))())(()((()())(())()(((()()))(()()()()))(...

output:

130680

result:

ok single line: '130680'

Test #91:

score: 0
Accepted
time: 101ms
memory: 39432kb

input:

100000 18
((())(()()()()())()()(())((())()()()())()()()()((()()())((()))()()(()())()()()())(()())()(()(())))(()()((()()))(())()()(()())()(()())((()())()()(())()())((())(()))(()()()))((())(()())()(((())))(()(()))(()(()))()(())()(((())())()()())((())))((()())((()())))((()))(()(()()()()((())))()(()))((...

output:

525576

result:

ok single line: '525576'

Test #92:

score: 0
Accepted
time: 108ms
memory: 38904kb

input:

100000 24
((((((())()((())))()()(())((()())())()()(((()))()()(((())))())(()())(()(()()(())((()())(()())))(()())()(()(())()())(()((()))))()(((()(()()))())())((()))()()(()(()))())((()()()()(()(()))(()))()(()))()(((()))(()()(()(()))())()((()()())()((())(())((())(())()()())()())((())))()((()())((()()()(...

output:

118587

result:

ok single line: '118587'

Test #93:

score: 0
Accepted
time: 112ms
memory: 36540kb

input:

100000 30
((((())()()(((()()())())))((()))(())(()()(())))((())())((())(())())(((()(()(()))())(()())()()(())))(((()())(()))()((())((())()())((())()()()())()()()(())()()(()()))(((()()))(()()())(()(()()(())()))(())((())(()))(())()(()))))(((())(()()())()()((()))(()(()()()()((())))))((((()()()))(()((()))...

output:

132047

result:

ok single line: '132047'

Test #94:

score: 0
Accepted
time: 161ms
memory: 39284kb

input:

99999 2
()))())))))()))()))(()()))())))())(()))(((())(()(((()))(((()((((((((((((()))(())()(()((())(()())(())())()())()())()(()(((())())()(()(())(()))))))))))()))()()))())()(()())))((()(()((()))))))(()()())))()((())))))((()(((()()(())())()()))(())())())())))(())))(())()))())())(((((()()((((((()()(())...

output:

97853

result:

ok single line: '97853'

Test #95:

score: 0
Accepted
time: 142ms
memory: 40156kb

input:

100000 5
)()()())(()())()()(())()))(()((())))(((((()())()((())()((()))()))(((()))(((()())((())((()())())()())))((((()))))(()((())(((()))(()((((()(())(((()(((()()))))((()((()(()(()((((()()()()(((()())))(((()(()()))))))()(()))((())()(((()(()())))))(((((()(())())(((()())()(())(()))()()()))()()())(((())...

output:

96190

result:

ok single line: '96190'

Test #96:

score: 0
Accepted
time: 148ms
memory: 39360kb

input:

100000 15
)())((()))()((()()((()())()(((((())())()()((((()()(()())()(()((())))))(()()(()(()((())))))())(()())()))))())())()())()()(((((()()()()))))(((((()())())(()((()())()))(()()((()()((()((()))(((())()))(())((())(())))))())()((()()))(((())((()((()())(())))()()(())))(())(()()())))()())()((()(()(()(...

output:

93249

result:

ok single line: '93249'

Test #97:

score: -1
Wrong Answer
time: 140ms
memory: 38960kb

input:

100000 29
)()()))))()(()()()))(()())()(((())()))()())))())(((())()())))))))))(((())())((()(())()))(()))())())((((((((()(()((((())()())(()())))())((()())(()))(()())()())(((()()())()(()))((((((()(())((())))((()))(((())(())(()))(())()(())((()())(((()(()((()(())((()()(()()(((())()))()(())))((()()))(()))...

output:

91678

result:

wrong answer 1st lines differ - expected: '91679', found: '91678'

Subtask #7:

score: 0
Wrong Answer

Test #103:

score: 1
Accepted
time: 92ms
memory: 38264kb

input:

80000 81
((((((()())((()((()))))(()())()(()(((()(()())(()())())(())))()(())(()()))()))(((()(()))((()))(())((((())))(())()((()))())((()(()())))(())(()()))(((()()))(()((())))())()(((()()))(()())()()(((()((()))(())))((())(()((())))())(()())))()()()((()()(()()(())()()((()))(())()))((()(())()()))(()(()()...

output:

87799

result:

ok single line: '87799'

Test #104:

score: -1
Wrong Answer
time: 89ms
memory: 39036kb

input:

80000 729
(((())(()))(()()())(()(()))(()())(()()()())(((()()())))()(()()()(()())))(((())((()()())))())((()(())()()())((()()()))()(()()()())()()(((())(()))(()())()()()(())))((()))((()())()(()()())(()()()()())(())(((()))(()(()())())())(()()())(()(())()()()()(())())()())(((())()))(((()())(())()(())((()...

output:

76293

result:

wrong answer 1st lines differ - expected: '76309', found: '76293'

Subtask #8:

score: 0
Wrong Answer

Test #129:

score: 1
Accepted
time: 83ms
memory: 37884kb

input:

79856 243
(())()(())(())(()()())()(())()(()())()(())()(())()((()))(())(()(())())()(()())()()(())(())((()()))(())(()()())(()())((()())()())(())()()(())()(())((()()))()()(()()())(())()()(()())(())(())((()))(())(())()()()()()(()(()))(()(())()(()))()()()()()()()()((()()))()()()()()(())()(())(()())()(()(...

output:

794572

result:

ok single line: '794572'

Test #130:

score: -1
Wrong Answer
time: 83ms
memory: 38288kb

input:

79156 2187
((((((())))((()))()(()(())()()())(()))((()(())()))((((())()))(()(((()()))())(()())(())(())(()()(())(()))(((())))(()()))()(((()()()))(()(()())))(((())(()(()))(())()())()()(())))((())()(())())(((()()()()())(())(())()((((()))(())())))((()(()()))((()()))())(())(()(()(()))()()()())((()()())())...

output:

43604

result:

wrong answer 1st lines differ - expected: '43675', found: '43604'

Subtask #9:

score: 0
Wrong Answer

Test #155:

score: 1
Accepted
time: 108ms
memory: 39608kb

input:

99599 64
((((((()(((())()))))((((((()))()())())())(()(()(()())))(()(()()(())())((()(()()))((()))()(())()())()(()(())()((()()())()())()(((())()))(()))((())(()(())()))(()))())()(((())(((())()((())))())(()()(()))(()())()((())((()())()(())())(())()(())((())(()()(()))((()))(()()())))()(((()))(())))(())((...

output:

110447

result:

ok single line: '110447'

Test #156:

score: -1
Wrong Answer
time: 115ms
memory: 37292kb

input:

100000 1024
((((((((()()))(((()()()(((())())))()(((())))((())()(()()())(()()))((()())(())()()))))(((((())())()))))(((((((()))))())(((())()()((())))((()()))())()(()()())((()()(((()))()())(()(()()))()((()(()))(())()(())()()(()())())()((()))(())())()()))())(((()()((()(())()))(()))((()())((()()()))()(()...

output:

74449

result:

wrong answer 1st lines differ - expected: '74496', found: '74449'

Subtask #10:

score: 0
Wrong Answer

Test #181:

score: 1
Accepted
time: 113ms
memory: 38856kb

input:

100000 256
((((())()(())())(((()))()((())()(()(())))))(((()(()))(((()))()()()()))()((((()))(())((()))))((()))(()((()()()()())()())(())(())()()(()()))(((()()))))())((((()))()((())()(()(())((()))))()((()()()()((()))))()(()(()()(()(())(()))))(())(((())))((()()((()))()())()())()((()())))()(((((()()))))(...

output:

107402

result:

ok single line: '107402'

Test #182:

score: -1
Wrong Answer
time: 108ms
memory: 38884kb

input:

99728 4096
((((((()((()))))()))((((((()()(()())))(())()(()))()(()()()()()((()()()))()(((()))()(()))((()))(()()())()()))())(((()))(())((()((())()(()()))()))()(((())(())(()))(())((()(()(())()())()))((()())()())(()())(((()()()(())))))())(((())()())((()())())((()((()()())()()))()((()))))(()(((()((()))))...

output:

41856

result:

wrong answer 1st lines differ - expected: '41913', found: '41856'