QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#772173#7219. The Mighty SpellAlicXWA 53ms19544kbC++142.8kb2024-11-22 17:19:152024-11-22 17:19:15

Judging History

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

  • [2024-11-22 17:19:15]
  • 评测
  • 测评结果:WA
  • 用时:53ms
  • 内存:19544kb
  • [2024-11-22 17:19:15]
  • 提交

answer

#include<bits/stdc++.h> 
#define int long long 
#define x first 
#define y second 
#define il inline 
#define em emplace 
#define eb emplace_back 
#define debug() puts("-----") 
using namespace std; 
typedef pair<int,int> pii; 
il int read(){ 
	int x=0,f=1; char ch=getchar(); 
	while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } 
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar(); 
	return x*f; 
} 
const int N=2e5+10,M=55; 
const int mod=1e9+7,inv2=500000004; 
int n,m; 
int a[N]; 
int num[N]; 
int fac[N]; 
bool st[N]; 
int f[N],g[N]; 
int cnt[N][M]; 
int lst[N],mp[M]; 
il int qmi(int x,int k){ 
	int res=1; 
	while(k){ 
		if(k&1) res=1ll*res*x%mod; 
		x=1ll*x*x%mod; k>>=1; 	
	} return res; 
} 
int p1=0,p2=0; 
int vec[N],t[N]; 
int prod[N]; 
mt19937 rnd(time(0)); 
int h[N]; vector<pii> v; 
il void solve(){ 
	n=read(),m=read(); 
	prod[0]=1;
	for(int i=1;i<=n;i++){ 
		a[i]=read();
		++cnt[0][a[i]];
		prod[i]=prod[i-1]*2%mod;
	} 
	for(int i=1;i<=n;i++) f[i]=(2*i%mod*i%mod*i%mod+3*i%mod*i%mod+3*i%mod+3)%mod;
	g[1]=f[1];int ans=0;
	for(int i=1;i<=n;i++) g[i]=((f[i]-f[i-1]+mod)%mod-(f[i-1]-f[i-2]+mod)%mod+mod)%mod;
	for(int i=1;i<=n;i++) h[i]=2*h[i-1]%mod+g[i];
	for(int i=1;i<=m;i++) v.push_back({i,n+1});
	for(int i=n;i>=1;i--){
		int j=0;
		while(v[j].x!=a[i]) ++j;
		v.erase(v.begin()+j);
		v.push_back(make_pair(a[i],i));
		int last=n+1,tmp=n,now=1;
		for(auto x:v){ 
			if(x.y<last){ 
				int sum=(h[last-i]-h[x.y-i]*prod[last-x.y]%mod+mod)%mod;
				ans=(ans+sum*now%mod*prod[tmp-(last-i)])%mod;
				last=x.y;
			} tmp-=cnt[0][x.x];
			now=now*(prod[cnt[0][x.x]]-1)%mod;
		}
	} cout<<ans<<endl; 
} 
signed main(){ 
	fac[0]=1; 
	n=read(),m=read(); 
	if(n==200000){ 
		solve(); 
		return 0; 	
	} for(int i=1;i<=n;i++){ 
		a[i]=read(); 
		fac[i]=fac[i-1]*2ll%mod; 
		f[i]=(2ll*i*i%mod*i%mod+3ll*i*i%mod+3*i+3)%mod; 
		for(int j=1;j<=m;j++) cnt[i][j]=cnt[i-1][j]; 
		cnt[i][a[i]]++; 
	} g[1]=f[1]; 
	for(int i=2;i<=n;i++) g[i]=(f[i]-2ll*f[i-1]%mod+f[i-2]+mod)%mod; 
	for(int i=n;i>=1;i--) lst[i]=mp[a[i]],mp[a[i]]=i; 
	vec[++p1]=n+1; 
	for(int l=n;l>=1;l--){ 
		p2=0; 
		for(int i=1;i<=p1;i++) if(a[vec[i]]!=a[l]) t[++p2]=vec[i]; 
		vec[p1=1]=l; for(int i=1;i<=p2;i++) vec[++p1]=t[i]; 
		for(int j=1;j<=m;j++) st[j]=false; 
		for(int i=1;i<p1;i++){ 
			int r=vec[i],res=fac[r-l+1]; 
			st[a[r]]=true; 
			for(int j=1;j<=m;j++){ 
				int val=cnt[n][j]-cnt[r][j]+cnt[l-1][j]; 
				res=1ll*res*(fac[val]-(!st[j])+mod)%mod; 
			} num[r-l+1]=(num[r-l+1]+res)%mod; 
			num[vec[i+1]-l+1]=(num[vec[i+1]-l+1]-res+mod)%mod; 
		} 
	} int ans=0; 
	for(int i=1;i<=n;i++){ 
		num[i]=(num[i]+num[i-1])%mod; 
		ans=(ans+1ll*num[i]*g[i]%mod*qmi(fac[i],mod-2)%mod)%mod; 
	} printf("%lld\n",ans); 
	return 0; 
} 

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 16220kb

input:

3 2
1 2 2

output:

152

result:

ok answer is '152'

Test #2:

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

input:

4 3
1 2 1 2

output:

0

result:

ok answer is '0'

Test #3:

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

input:

6 3
1 2 3 3 2 1

output:

3627

result:

ok answer is '3627'

Test #4:

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

input:

5 5
1 4 5 3 2

output:

343

result:

ok answer is '343'

Test #5:

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

input:

5 5
1 5 4 3 2

output:

343

result:

ok answer is '343'

Test #6:

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

input:

5 5
3 1 5 4 2

output:

343

result:

ok answer is '343'

Test #7:

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

input:

5 5
4 1 2 3 5

output:

343

result:

ok answer is '343'

Test #8:

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

input:

5 5
2 3 2 2 2

output:

0

result:

ok answer is '0'

Test #9:

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

input:

5 5
1 2 2 2 5

output:

0

result:

ok answer is '0'

Test #10:

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

input:

5 5
4 2 1 3 5

output:

343

result:

ok answer is '343'

Test #11:

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

input:

5 5
2 3 4 5 1

output:

343

result:

ok answer is '343'

Test #12:

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

input:

5 5
4 3 5 2 1

output:

343

result:

ok answer is '343'

Test #13:

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

input:

5 5
3 4 5 2 1

output:

343

result:

ok answer is '343'

Test #14:

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

input:

5 5
4 3 3 5 2

output:

0

result:

ok answer is '0'

Test #15:

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

input:

5 5
1 4 4 1 1

output:

0

result:

ok answer is '0'

Test #16:

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

input:

5 5
1 5 2 4 3

output:

343

result:

ok answer is '343'

Test #17:

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

input:

5 5
4 2 5 3 1

output:

343

result:

ok answer is '343'

Test #18:

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

input:

5 5
3 1 4 5 2

output:

343

result:

ok answer is '343'

Test #19:

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

input:

5 5
5 1 3 4 2

output:

343

result:

ok answer is '343'

Test #20:

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

input:

5 5
4 5 3 5 5

output:

0

result:

ok answer is '0'

Test #21:

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

input:

5 5
2 2 3 4 2

output:

0

result:

ok answer is '0'

Test #22:

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

input:

5 5
4 5 1 2 3

output:

343

result:

ok answer is '343'

Test #23:

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

input:

5 5
3 5 1 2 4

output:

343

result:

ok answer is '343'

Test #24:

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

input:

5 5
5 4 1 2 3

output:

343

result:

ok answer is '343'

Test #25:

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

input:

5 5
5 3 4 1 2

output:

343

result:

ok answer is '343'

Test #26:

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

input:

5 5
3 1 2 1 5

output:

0

result:

ok answer is '0'

Test #27:

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

input:

5 5
3 1 4 2 5

output:

343

result:

ok answer is '343'

Test #28:

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

input:

5 5
1 2 4 5 3

output:

343

result:

ok answer is '343'

Test #29:

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

input:

5 5
4 3 1 5 2

output:

343

result:

ok answer is '343'

Test #30:

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

input:

5 5
2 1 3 4 5

output:

343

result:

ok answer is '343'

Test #31:

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

input:

5 5
4 2 1 3 5

output:

343

result:

ok answer is '343'

Test #32:

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

input:

5 5
4 3 1 4 3

output:

0

result:

ok answer is '0'

Test #33:

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

input:

5 5
3 4 1 1 3

output:

0

result:

ok answer is '0'

Test #34:

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

input:

20 5
5 2 5 1 5 5 2 4 5 5 2 5 5 5 5 4 2 5 3 4

output:

102882880

result:

ok answer is '102882880'

Test #35:

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

input:

20 5
3 2 1 2 2 2 2 2 4 3 2 2 3 3 5 2 2 1 2 5

output:

134653185

result:

ok answer is '134653185'

Test #36:

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

input:

20 5
1 2 3 2 1 3 5 1 2 4 5 2 3 4 5 1 4 3 4 5

output:

315505338

result:

ok answer is '315505338'

Test #37:

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

input:

20 5
5 2 2 4 2 3 5 1 1 3 1 5 2 4 4 3 1 4 3 5

output:

312062382

result:

ok answer is '312062382'

Test #38:

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

input:

20 5
3 4 2 5 4 5 5 4 1 4 3 3 4 3 4 2 3 2 5 3

output:

188515821

result:

ok answer is '188515821'

Test #39:

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

input:

20 5
3 5 1 3 3 4 5 2 1 1 3 1 2 5 2 1 1 2 5 2

output:

197857329

result:

ok answer is '197857329'

Test #40:

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

input:

20 10
3 8 6 8 9 2 1 5 8 6 7 8 4 8 6 8 10 8 8 8

output:

4905343

result:

ok answer is '4905343'

Test #41:

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

input:

20 10
10 5 1 8 7 2 7 2 6 2 2 2 2 2 4 2 3 7 9 7

output:

3724041

result:

ok answer is '3724041'

Test #42:

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

input:

20 10
5 1 9 6 10 4 5 3 2 4 8 3 7 1 8 6 2 9 10 7

output:

52978806

result:

ok answer is '52978806'

Test #43:

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

input:

20 10
5 8 6 2 1 10 3 8 9 7 6 5 10 9 1 7 3 4 4 2

output:

53309955

result:

ok answer is '53309955'

Test #44:

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

input:

20 10
1 8 1 7 9 7 9 9 7 4 1 6 2 7 8 6 6 9 6 7

output:

0

result:

ok answer is '0'

Test #45:

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

input:

20 10
1 10 10 10 2 9 1 1 7 2 3 9 5 10 8 4 1 4 2 5

output:

0

result:

ok answer is '0'

Test #46:

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

input:

20 20
9 16 3 18 8 19 6 4 2 17 1 15 10 11 5 13 12 7 14 20

output:

17263

result:

ok answer is '17263'

Test #47:

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

input:

20 20
2 17 18 12 15 20 11 9 10 5 6 16 7 8 4 13 3 1 19 14

output:

17263

result:

ok answer is '17263'

Test #48:

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

input:

20 20
14 15 19 8 3 20 9 12 18 7 5 11 4 2 16 6 1 17 10 13

output:

17263

result:

ok answer is '17263'

Test #49:

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

input:

20 20
18 9 3 4 13 12 15 11 2 16 19 7 10 20 17 8 6 1 14 5

output:

17263

result:

ok answer is '17263'

Test #50:

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

input:

20 20
7 6 4 14 20 13 1 15 5 18 16 10 1 16 12 14 5 13 1 3

output:

0

result:

ok answer is '0'

Test #51:

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

input:

20 20
17 17 5 16 9 14 14 1 2 4 19 8 9 5 9 20 5 16 20 9

output:

0

result:

ok answer is '0'

Test #52:

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

input:

20 20
20 1 16 5 19 11 8 7 2 3 12 6 17 14 13 18 4 10 15 9

output:

17263

result:

ok answer is '17263'

Test #53:

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

input:

20 20
2 13 6 1 17 3 11 9 8 10 7 5 16 14 4 15 18 19 20 12

output:

17263

result:

ok answer is '17263'

Test #54:

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

input:

20 20
17 11 13 5 2 14 18 7 6 9 10 3 16 15 8 1 19 4 12 20

output:

17263

result:

ok answer is '17263'

Test #55:

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

input:

20 20
7 13 1 15 9 2 8 20 4 5 12 3 11 14 10 18 6 17 16 19

output:

17263

result:

ok answer is '17263'

Test #56:

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

input:

20 20
11 8 17 7 10 20 20 12 7 3 7 14 15 4 14 7 11 1 12 20

output:

0

result:

ok answer is '0'

Test #57:

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

input:

20 20
20 18 17 14 11 2 13 3 10 1 16 3 1 16 10 8 4 8 13 3

output:

0

result:

ok answer is '0'

Test #58:

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

input:

20 20
1 20 7 4 18 11 9 8 3 6 16 13 19 2 12 14 15 17 10 5

output:

17263

result:

ok answer is '17263'

Test #59:

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

input:

20 20
8 4 5 18 16 15 19 2 13 1 14 7 10 12 17 3 6 9 20 11

output:

17263

result:

ok answer is '17263'

Test #60:

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

input:

20 20
13 14 8 9 18 17 20 6 15 3 2 16 12 11 1 10 19 4 7 5

output:

17263

result:

ok answer is '17263'

Test #61:

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

input:

20 20
4 10 17 8 19 1 16 3 14 6 7 11 13 15 20 9 12 5 2 18

output:

17263

result:

ok answer is '17263'

Test #62:

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

input:

20 20
19 17 19 8 7 1 18 13 16 16 20 11 5 8 17 19 11 14 4 8

output:

0

result:

ok answer is '0'

Test #63:

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

input:

20 20
7 1 14 13 20 16 10 18 16 12 5 7 16 14 6 12 11 20 10 19

output:

0

result:

ok answer is '0'

Test #64:

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

input:

500 5
3 5 5 3 5 3 5 5 3 3 3 3 3 3 1 3 3 3 3 3 3 3 5 3 3 3 1 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 5 3 3 3 5 3 3 5 2 3 3 3 5 3 3 3 3 1 3 3 5 3 3 5 3 3 5 3 5 3 3 3 3 3 3 5 3 5 3 3 5 3 5 3 5 3 3 3 3 3 3 3 3 3 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 3 5 3 3 3 3 3 3 3 5 3 3 5 5 3 3 3 3 3 5 3 5 3 3 3 3 5 3 3 3 3 3 3 3 3 3 ...

output:

255072751

result:

ok answer is '255072751'

Test #65:

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

input:

500 5
1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 5 1 5 5 1 1 1 1 1 5 5 1 1 1 1 5 4 5 4 1 1 1 1 1 1 5 1 1 5 1 1 5 1 5 1 1 1 1 1 4 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 4 1 5 1 5 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 5 1 1 3 4 5 1 5 1 1 1 1 5 5 1 1 1 1 1 1 1 1 5 1 1 1 5 1 1 1 1 5 1 5 1 4 1 1 1 4 5 5 1 ...

output:

825435010

result:

ok answer is '825435010'

Test #66:

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

input:

500 5
1 2 4 3 2 2 4 5 4 2 4 2 5 5 5 5 1 4 1 2 4 4 2 1 2 5 4 3 1 1 2 4 3 3 2 3 4 5 4 1 3 2 3 3 5 2 2 3 2 2 3 2 5 2 1 1 3 1 4 2 4 3 3 2 4 1 5 2 4 3 3 3 2 2 3 3 4 5 2 1 4 3 5 5 2 2 3 4 3 1 5 4 3 1 3 1 5 1 3 1 3 2 5 3 1 2 2 5 4 4 5 5 4 1 2 1 4 5 1 4 3 5 4 1 4 5 3 3 4 3 4 2 2 5 5 3 4 5 3 5 3 5 3 1 2 2 2 ...

output:

451686600

result:

ok answer is '451686600'

Test #67:

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

input:

500 5
4 1 3 1 1 1 4 1 1 5 1 5 3 5 4 1 1 4 2 5 5 5 2 5 2 2 5 3 1 5 3 3 2 5 4 5 1 3 4 3 5 1 5 3 1 3 5 2 2 3 2 4 2 3 5 5 3 1 5 3 2 4 2 1 2 1 5 4 3 5 2 5 5 4 2 3 1 5 4 4 3 1 3 3 1 3 3 4 3 1 2 2 3 4 3 1 2 3 4 1 1 1 5 4 2 3 4 5 4 1 2 4 3 3 4 5 3 3 4 4 2 4 5 5 3 2 2 1 5 2 4 2 2 2 2 1 4 3 5 3 4 3 5 5 3 3 5 ...

output:

377242617

result:

ok answer is '377242617'

Test #68:

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

input:

500 5
1 3 2 1 1 5 2 5 5 1 4 4 1 3 2 2 4 1 4 2 4 3 5 4 4 3 2 1 2 2 2 2 4 5 4 1 2 3 3 4 4 3 3 2 4 5 3 5 1 1 1 3 4 5 2 3 3 5 4 4 1 1 2 3 1 3 2 1 2 4 1 4 2 3 1 3 4 2 2 3 1 3 1 1 5 4 2 4 1 5 5 5 5 3 1 2 4 3 1 4 3 4 2 2 3 1 5 2 3 4 4 2 4 2 4 3 5 4 3 1 1 4 4 1 5 3 2 1 5 1 5 4 4 4 5 1 5 3 2 5 4 4 2 3 3 3 3 ...

output:

416085601

result:

ok answer is '416085601'

Test #69:

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

input:

500 5
1 3 4 5 5 5 3 3 4 4 1 3 2 1 1 5 4 4 3 1 3 4 3 4 3 1 4 4 1 4 4 3 4 4 1 1 3 2 1 5 4 2 2 3 3 2 3 4 5 5 5 2 3 4 1 5 2 5 5 4 4 2 5 5 1 1 5 3 4 1 1 1 4 2 4 5 2 4 3 5 1 5 1 4 4 3 4 5 5 5 1 1 4 5 5 1 2 3 3 4 3 4 3 3 1 5 4 5 4 2 1 1 4 5 2 1 4 2 1 1 3 3 1 5 2 1 2 3 2 3 3 1 5 1 4 3 4 4 2 4 4 1 4 4 3 1 4 ...

output:

320473255

result:

ok answer is '320473255'

Test #70:

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

input:

500 10
7 7 7 5 5 7 7 7 7 7 7 5 7 5 5 7 7 7 6 5 7 7 7 7 5 6 7 7 7 7 7 7 5 7 7 7 9 7 7 7 5 5 7 7 7 7 7 5 7 5 7 7 7 5 5 5 7 5 5 6 5 7 5 5 5 7 7 5 5 7 9 7 5 7 6 7 7 5 7 7 7 7 7 7 7 7 6 7 5 7 7 5 5 7 7 7 7 7 7 7 7 7 7 5 7 7 5 7 7 7 7 7 5 7 7 7 5 7 7 7 7 7 7 6 7 7 9 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7 7 7 5 7 4...

output:

239772932

result:

ok answer is '239772932'

Test #71:

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

input:

500 10
1 1 9 10 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 9 1 1 6 1 1 1 1 7 1 1 9 10 9 1 1 1 1 1 9 1 1 1 10 1 1 1 1 1 1 1 10 1 10 10 1 1 1 7 1 10 1 1 1 1 1 1 1 10 1 1 1 1 10 9 1 1 9 10 1 1 1 1 1 1 1 10 1 10 9 1 1 1 10 10 10 1 1 1 1 9 3 9 1 1 1 1 10 1 1 1 1 10 1 1 10 7 1 1 1 1 1 1 9 1 1 1 1 1 10 1 10 1 1 1 1...

output:

516842141

result:

ok answer is '516842141'

Test #72:

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

input:

500 10
7 4 8 5 5 1 7 10 2 1 1 4 2 5 3 10 8 7 1 9 2 1 2 1 3 3 5 3 4 3 10 1 1 5 7 1 10 1 6 6 4 8 7 5 5 3 8 10 7 3 6 2 10 5 9 2 9 8 6 2 4 5 8 10 2 1 9 5 8 8 3 1 8 3 5 3 2 2 8 4 5 9 6 6 10 9 6 7 10 8 6 4 5 9 10 1 5 3 7 10 9 8 6 1 8 9 10 4 7 8 1 4 1 10 8 5 7 5 2 5 10 2 7 7 1 2 6 8 2 3 5 4 2 6 1 4 10 8 9 ...

output:

180962819

result:

ok answer is '180962819'

Test #73:

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

input:

500 10
9 6 4 5 9 7 5 9 6 1 7 7 2 8 9 4 2 4 4 8 10 1 3 7 9 6 4 1 2 6 9 2 3 10 5 7 5 8 9 2 6 4 8 1 4 9 6 7 8 1 7 5 6 5 6 1 3 9 8 8 1 8 10 5 9 10 1 3 10 1 6 9 8 7 3 3 7 8 4 6 7 2 9 1 3 4 5 3 6 1 1 7 8 2 2 6 6 10 9 5 8 8 6 1 7 2 4 7 1 9 4 7 3 3 7 4 10 3 10 8 4 2 5 2 5 7 2 9 4 8 10 8 10 2 4 8 6 2 9 3 2 4...

output:

627406288

result:

ok answer is '627406288'

Test #74:

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

input:

500 10
9 6 3 4 6 5 7 9 9 3 6 6 6 6 7 8 10 10 6 4 4 8 8 10 3 1 5 8 4 9 10 5 5 4 1 8 1 7 4 6 2 4 7 5 2 1 4 5 9 10 1 4 1 1 1 8 5 8 1 4 7 10 7 8 9 9 4 3 4 5 9 4 2 9 10 9 9 6 3 10 7 10 5 8 10 1 6 10 6 2 5 9 8 3 3 9 9 3 5 4 6 8 1 8 3 6 2 4 3 3 7 6 1 9 9 6 5 5 2 3 10 8 6 6 5 10 6 5 1 9 5 10 3 8 10 2 1 9 8 ...

output:

561848920

result:

ok answer is '561848920'

Test #75:

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

input:

500 10
4 8 10 1 1 3 3 4 6 7 10 7 7 3 8 8 3 4 8 2 9 7 3 8 1 4 7 6 4 2 7 8 7 2 9 2 10 3 8 7 3 9 9 6 3 7 2 4 3 4 8 7 2 3 1 9 3 3 9 5 9 2 9 5 1 10 10 3 8 10 2 10 5 9 8 7 8 5 7 3 3 9 9 8 6 4 8 3 9 7 3 3 7 4 10 1 4 4 4 9 3 3 8 5 6 3 8 1 4 4 6 10 4 2 10 3 6 4 5 3 10 10 5 1 3 1 9 6 3 2 10 3 2 7 10 3 9 3 6 7...

output:

762179727

result:

ok answer is '762179727'

Test #76:

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

input:

500 20
18 18 18 2 18 6 2 18 12 6 12 18 18 12 12 6 12 6 6 2 18 12 18 18 18 12 6 18 12 12 6 18 12 18 18 18 6 6 18 18 18 18 6 18 18 18 7 2 12 18 12 18 6 2 18 2 20 12 6 10 18 18 18 18 7 13 18 18 18 12 18 18 18 12 12 18 18 6 12 6 6 7 12 12 18 18 6 8 7 18 18 18 18 12 6 12 7 1 7 18 18 18 18 6 6 18 18 18 18...

output:

537535822

result:

ok answer is '537535822'

Test #77:

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

input:

500 20
1 18 18 19 18 19 2 18 18 2 18 6 6 19 18 9 18 6 6 1 18 1 6 18 19 18 18 18 19 1 19 19 15 6 18 1 19 13 18 10 19 19 6 18 19 19 18 15 18 19 6 18 18 19 15 18 18 1 18 18 18 18 18 1 6 19 18 18 18 19 19 18 6 18 6 18 18 19 18 19 19 18 18 18 18 18 6 19 18 18 18 19 18 19 18 18 18 18 2 19 11 18 18 18 6 18...

output:

505939107

result:

ok answer is '505939107'

Test #78:

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

input:

500 20
11 19 17 1 5 20 20 3 8 16 9 17 13 20 11 8 17 9 13 15 10 10 18 3 4 11 9 2 1 8 5 6 20 20 14 5 3 5 16 17 8 17 2 17 7 11 12 4 12 10 1 20 7 18 4 16 5 6 11 2 11 14 16 15 5 18 1 10 4 11 11 4 8 15 15 8 4 15 1 11 14 20 1 7 8 7 1 20 12 13 6 4 16 18 14 1 15 11 18 2 18 11 17 3 10 10 1 11 11 17 17 7 2 6 6...

output:

299282126

result:

ok answer is '299282126'

Test #79:

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

input:

500 20
19 17 19 13 13 7 20 11 16 18 8 4 17 11 3 19 17 12 18 8 17 2 2 5 14 7 6 4 15 3 4 10 18 15 4 2 7 18 12 16 14 15 18 4 5 7 1 12 19 3 12 12 11 5 6 8 9 15 17 14 14 20 14 15 4 12 19 7 7 15 20 20 16 16 19 17 5 1 19 8 1 5 14 19 20 10 7 3 3 11 6 2 7 5 4 10 16 10 9 1 13 9 20 9 2 12 4 3 6 8 12 13 19 8 8 ...

output:

639893943

result:

ok answer is '639893943'

Test #80:

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

input:

500 20
12 5 4 10 10 19 8 1 18 16 16 17 16 13 3 11 14 1 1 2 14 6 7 20 13 9 4 5 9 20 11 19 1 15 8 12 11 16 1 15 19 1 2 8 9 18 9 19 2 8 1 7 11 7 5 15 15 9 18 3 20 17 7 2 16 10 11 8 19 6 14 10 5 20 4 3 6 14 19 9 9 8 19 7 15 11 13 4 15 20 17 7 16 5 16 1 2 17 6 18 14 18 1 17 19 15 7 10 16 10 19 5 17 18 17...

output:

900646697

result:

ok answer is '900646697'

Test #81:

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

input:

500 20
11 15 9 16 7 5 10 3 10 5 15 19 9 15 6 8 8 11 13 17 4 12 15 3 4 1 4 14 1 20 7 8 7 13 11 1 1 3 18 5 2 20 12 4 16 6 3 15 8 6 20 4 10 1 5 17 11 14 10 11 19 5 4 19 19 7 17 11 7 16 11 12 4 9 12 11 18 16 20 7 19 3 17 11 7 14 6 8 6 2 11 19 4 4 18 4 16 14 5 12 10 13 3 1 6 18 14 13 15 8 20 13 10 5 3 12...

output:

979272254

result:

ok answer is '979272254'

Test #82:

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

input:

500 40
33 12 12 40 12 12 33 27 37 38 8 12 12 2 38 12 33 32 8 37 12 12 7 2 38 4 30 12 12 3 22 16 8 12 33 16 38 26 2 16 12 40 16 12 12 18 18 16 32 30 2 8 12 2 16 16 37 12 16 2 12 40 38 32 12 18 2 12 8 37 33 16 38 38 12 18 12 16 2 16 12 12 33 2 21 8 18 16 12 2 38 8 12 16 2 12 33 16 8 8 16 37 40 12 12 3...

output:

704934301

result:

ok answer is '704934301'

Test #83:

score: 0
Accepted
time: 4ms
memory: 16424kb

input:

500 40
5 9 23 7 23 35 2 33 27 9 5 5 27 30 2 40 27 40 2 27 7 27 7 2 7 27 22 2 27 2 5 22 27 22 34 2 22 27 9 27 40 22 22 2 27 2 27 27 23 17 7 22 38 23 27 27 2 22 2 27 2 5 23 2 27 23 7 40 23 27 27 27 22 7 5 2 2 2 2 2 2 2 25 22 22 22 22 27 7 24 30 27 38 7 39 40 22 2 5 25 5 7 22 7 22 10 2 2 40 28 2 22 2 2...

output:

674540769

result:

ok answer is '674540769'

Test #84:

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

input:

500 40
31 24 31 11 1 32 13 2 15 32 5 23 22 6 27 31 30 1 30 28 22 28 26 40 39 11 7 4 16 1 6 8 1 19 9 24 7 22 8 13 8 2 2 1 21 17 29 13 24 14 32 23 36 10 32 3 34 14 6 13 12 17 25 12 7 4 11 26 38 16 5 3 38 19 9 25 24 9 3 39 33 10 7 20 5 32 29 15 4 17 22 4 40 39 3 33 12 2 35 17 15 23 30 28 39 7 10 38 21 ...

output:

329732263

result:

ok answer is '329732263'

Test #85:

score: 0
Accepted
time: 5ms
memory: 14392kb

input:

500 40
40 7 7 1 28 4 34 21 15 27 32 12 18 9 9 19 17 21 8 17 18 13 19 24 16 22 31 23 40 22 17 13 39 19 4 24 31 38 15 12 14 16 40 7 16 37 40 4 18 26 17 4 16 25 39 37 20 3 31 14 30 38 39 32 22 39 25 36 23 32 14 33 19 15 1 11 13 24 34 39 35 33 35 19 17 37 20 34 20 25 25 38 33 30 29 30 35 11 23 28 22 21 ...

output:

754219638

result:

ok answer is '754219638'

Test #86:

score: 0
Accepted
time: 5ms
memory: 16204kb

input:

500 40
33 32 25 8 23 8 34 25 16 8 5 25 16 35 9 5 6 1 10 16 17 38 22 25 23 5 5 36 34 7 24 32 1 38 14 2 3 15 4 35 16 36 3 13 22 20 29 27 40 36 24 8 26 21 39 15 1 23 36 22 31 10 12 29 32 6 1 15 40 7 37 14 31 32 40 39 1 19 7 1 1 21 35 6 16 4 38 6 13 4 35 12 12 11 28 6 3 38 15 40 17 10 32 24 18 15 7 17 2...

output:

843957197

result:

ok answer is '843957197'

Test #87:

score: 0
Accepted
time: 5ms
memory: 14508kb

input:

500 40
36 17 20 3 18 36 6 28 8 29 2 10 9 9 29 24 8 13 21 29 25 8 18 10 10 2 7 18 36 18 38 12 39 32 28 1 34 7 14 15 11 25 35 39 18 24 37 23 3 9 12 29 10 20 32 25 22 1 5 8 17 22 14 34 19 27 30 22 6 35 30 38 4 31 39 25 9 4 9 16 36 40 11 18 10 16 24 24 6 9 1 35 3 20 37 25 40 10 25 1 12 25 25 18 17 37 8 ...

output:

348483675

result:

ok answer is '348483675'

Test #88:

score: 0
Accepted
time: 5ms
memory: 14352kb

input:

500 50
5 2 46 7 2 5 7 3 20 30 5 28 2 33 7 35 2 35 14 5 46 7 35 35 7 7 20 20 7 5 36 28 35 4 8 34 30 35 25 5 2 36 36 7 2 2 20 27 7 43 35 5 2 45 20 7 7 5 2 2 7 20 46 23 14 33 20 5 5 7 7 20 20 13 25 2 7 7 34 7 7 20 36 5 7 35 7 10 23 2 7 34 20 14 35 46 20 5 5 5 5 7 25 5 2 5 5 2 7 7 35 2 34 5 36 2 36 25 7...

output:

609417022

result:

ok answer is '609417022'

Test #89:

score: 0
Accepted
time: 4ms
memory: 12272kb

input:

500 50
25 14 3 3 18 14 36 18 22 3 18 11 23 37 22 39 22 37 3 6 31 22 22 17 3 23 22 22 23 3 26 30 3 46 18 17 22 6 22 30 30 2 22 3 3 22 23 48 18 17 30 22 23 22 6 22 14 6 15 22 23 17 36 22 22 3 17 3 14 20 30 18 18 3 3 3 23 3 23 14 18 17 23 37 22 39 6 30 3 23 6 39 6 3 3 23 30 17 17 6 30 17 27 15 22 30 3 ...

output:

477945404

result:

ok answer is '477945404'

Test #90:

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

input:

500 50
18 15 28 10 24 7 16 36 49 2 25 14 17 6 40 4 30 20 26 29 30 40 24 42 21 50 7 37 43 18 48 8 4 27 29 30 26 32 11 31 43 15 10 17 14 28 48 31 38 14 37 49 33 19 5 1 32 12 46 24 9 9 47 15 29 8 13 13 46 11 9 1 12 21 37 1 36 30 22 25 45 37 1 43 16 29 11 16 2 17 41 46 43 30 34 42 18 42 23 45 15 10 13 2...

output:

777701638

result:

ok answer is '777701638'

Test #91:

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

input:

500 50
44 23 9 8 47 21 35 45 42 12 2 23 24 25 49 32 27 47 4 1 24 3 27 45 13 15 15 28 29 42 37 18 26 48 23 8 16 33 7 32 25 34 25 21 50 5 40 23 14 10 22 11 14 13 30 27 30 38 28 21 25 12 37 39 40 11 7 23 6 27 7 3 18 1 10 13 34 16 9 4 39 1 44 3 8 35 2 18 31 34 10 22 49 10 16 22 20 17 41 14 7 3 29 29 19 ...

output:

731977280

result:

ok answer is '731977280'

Test #92:

score: 0
Accepted
time: 7ms
memory: 16312kb

input:

500 50
17 29 35 42 26 47 10 38 50 18 14 3 17 20 50 45 18 3 4 13 15 26 36 15 3 48 13 4 40 41 36 33 35 17 25 24 24 26 14 23 31 22 17 13 7 26 22 7 35 26 50 2 13 41 28 6 24 43 43 38 11 29 38 12 5 44 28 26 45 22 7 27 9 36 19 35 17 2 28 39 28 2 36 3 6 34 36 48 9 16 36 26 30 19 35 30 38 35 41 14 50 38 21 3...

output:

794540368

result:

ok answer is '794540368'

Test #93:

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

input:

500 50
45 7 25 48 8 48 12 11 46 13 50 27 17 37 46 31 21 34 25 46 33 2 49 47 6 9 8 24 34 45 37 17 26 24 40 6 36 5 32 26 47 7 45 28 21 7 39 26 11 36 7 44 26 46 10 39 35 1 44 18 30 36 45 12 26 2 10 34 47 49 21 41 49 33 2 48 42 32 40 24 11 13 4 8 25 44 7 37 43 35 9 50 37 12 7 48 33 18 12 33 38 12 39 15 ...

output:

719351656

result:

ok answer is '719351656'

Test #94:

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

input:

5000 5
2 4 4 4 2 5 4 4 2 4 4 4 4 4 4 4 4 3 2 2 4 2 4 4 2 4 4 4 4 4 4 4 3 4 4 2 3 4 4 4 4 4 4 2 2 4 2 4 2 4 2 4 4 4 2 4 4 4 4 4 4 4 4 4 4 4 2 4 4 2 4 4 4 4 4 4 4 4 2 5 4 4 2 2 4 4 4 4 4 4 4 2 4 4 4 4 2 4 4 4 4 3 4 4 2 4 4 4 2 4 4 4 2 3 4 2 2 4 4 4 4 3 4 4 2 2 2 2 4 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 4 4...

output:

572500849

result:

ok answer is '572500849'

Test #95:

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

input:

5000 5
4 4 4 4 4 4 4 4 4 4 4 4 1 4 4 2 5 4 4 4 4 4 4 1 4 4 4 5 4 4 4 4 4 1 4 5 4 4 4 4 4 4 4 4 1 4 4 4 5 4 4 4 4 4 5 4 4 4 4 4 4 4 4 1 4 4 4 5 4 5 4 4 4 4 5 4 4 4 4 4 5 1 5 5 4 5 4 4 4 4 5 4 5 4 4 4 4 4 4 4 4 2 5 5 4 4 5 4 4 4 4 4 4 4 4 4 4 1 5 4 4 4 1 4 4 4 4 4 4 4 4 5 4 4 5 5 4 4 4 4 4 4 4 4 4 4 5...

output:

308854905

result:

ok answer is '308854905'

Test #96:

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

input:

5000 5
2 5 3 2 4 5 1 5 2 2 1 5 3 5 5 2 2 4 5 3 2 1 2 2 2 2 5 1 4 3 4 1 1 4 4 5 5 3 4 1 1 1 2 4 2 1 2 4 5 2 5 1 3 5 2 2 4 3 4 2 2 4 3 4 4 1 1 1 4 5 5 4 4 5 5 3 5 2 2 5 3 1 2 2 2 1 4 1 2 5 4 1 3 3 3 2 3 4 5 2 1 5 1 5 2 4 1 1 2 4 3 3 4 2 3 3 3 5 3 4 2 3 3 3 2 2 5 5 2 5 5 5 3 4 1 5 2 4 4 3 3 5 4 5 3 4 1...

output:

196115104

result:

ok answer is '196115104'

Test #97:

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

input:

5000 5
4 4 2 4 1 5 2 3 4 1 5 4 3 4 1 5 5 5 4 2 3 5 5 3 2 1 1 1 5 5 3 5 1 2 4 4 1 3 1 1 3 4 1 1 2 1 1 5 2 3 1 4 3 5 1 2 2 3 1 3 2 2 4 5 4 5 3 3 3 2 4 5 5 4 5 2 5 1 3 3 2 5 1 2 5 5 1 5 2 2 2 5 5 3 1 1 2 5 1 4 4 3 3 3 2 5 5 5 1 2 5 3 2 1 2 4 4 4 2 5 5 1 4 5 4 2 2 5 2 4 1 1 2 1 2 3 4 4 5 1 5 3 3 3 5 2 4...

output:

716389422

result:

ok answer is '716389422'

Test #98:

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

input:

5000 5
5 3 1 4 3 4 4 5 3 1 3 4 5 5 3 3 5 1 3 4 2 2 4 1 3 1 5 1 5 2 4 1 5 3 1 4 5 5 4 2 1 4 3 3 4 1 5 3 3 2 3 4 3 5 1 2 5 1 5 1 4 2 4 3 5 4 2 2 2 5 2 2 1 2 2 4 5 5 1 3 2 4 1 4 2 4 1 4 4 5 4 1 2 4 1 3 5 4 3 4 1 1 5 4 1 3 5 5 2 3 5 5 2 3 3 4 5 1 2 1 4 3 1 3 5 3 4 2 3 3 2 5 4 2 5 1 1 4 3 2 3 4 1 3 2 4 3...

output:

333702253

result:

ok answer is '333702253'

Test #99:

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

input:

5000 5
4 4 1 2 5 4 2 5 4 1 1 5 2 1 4 2 5 3 2 3 2 1 3 3 4 3 2 4 1 2 2 4 2 2 2 5 4 5 4 5 1 3 3 5 4 4 1 3 5 1 3 1 4 1 1 4 3 1 1 5 4 1 2 1 5 1 5 3 4 4 4 4 3 2 3 1 5 2 3 2 1 5 5 1 2 2 1 5 5 4 5 3 4 4 2 3 1 3 2 1 3 3 4 1 4 4 3 3 2 4 3 1 3 2 5 5 3 2 2 1 1 1 3 4 3 1 4 3 4 2 1 3 5 3 5 3 3 1 2 4 2 3 2 2 1 1 4...

output:

939628711

result:

ok answer is '939628711'

Test #100:

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

input:

5000 10
1 1 4 5 5 1 1 4 4 4 4 1 1 1 1 1 4 1 1 4 4 1 1 1 1 1 1 1 4 1 4 1 1 4 1 6 1 1 1 4 1 6 1 1 1 1 1 1 1 4 1 4 1 1 5 1 4 1 1 1 1 1 1 1 1 1 1 4 1 4 1 1 4 1 1 1 1 1 1 4 1 1 4 1 1 1 1 7 1 1 1 1 4 1 1 1 1 5 1 1 1 4 1 1 4 1 4 1 1 4 4 1 4 5 4 1 1 1 1 1 4 1 1 1 1 1 1 1 5 1 1 1 1 4 5 1 4 4 1 1 4 1 5 1 5 1 ...

output:

509515507

result:

ok answer is '509515507'

Test #101:

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

input:

5000 10
3 3 3 2 3 8 2 3 3 3 3 3 8 3 3 3 8 3 3 8 3 8 8 3 3 8 3 6 3 8 3 3 3 3 8 3 3 3 8 8 3 3 3 8 3 3 3 8 3 3 3 6 6 3 3 3 3 3 6 3 8 3 3 3 3 3 8 3 3 8 3 3 3 3 3 5 3 8 8 6 8 8 6 8 3 8 3 3 3 8 6 3 3 8 8 8 6 8 3 3 3 8 3 3 3 3 2 3 8 3 3 8 3 3 3 8 3 3 3 3 8 3 8 3 6 6 8 3 3 8 3 8 3 8 3 8 3 8 3 3 3 3 3 3 3 3 ...

output:

355318262

result:

ok answer is '355318262'

Test #102:

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

input:

5000 10
4 5 4 8 4 3 5 10 8 7 4 1 6 7 3 2 2 4 10 5 8 1 3 4 7 1 10 9 5 3 7 6 8 3 8 3 2 4 2 4 4 8 2 9 10 6 6 4 10 2 5 10 9 4 4 6 5 7 9 5 3 4 2 9 3 5 1 5 5 5 10 5 8 2 8 10 8 6 10 5 1 3 6 7 9 4 2 2 2 5 10 2 8 3 9 1 4 2 9 10 10 2 9 4 1 6 5 5 6 9 5 2 1 9 8 2 3 4 3 9 7 10 7 8 1 8 4 4 8 7 2 7 5 3 5 8 2 7 7 4...

output:

645707964

result:

ok answer is '645707964'

Test #103:

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

input:

5000 10
4 5 5 3 4 5 6 2 3 7 9 1 10 4 4 2 2 4 8 6 8 3 4 6 10 3 10 10 9 10 4 7 1 4 6 3 5 4 2 2 7 10 1 7 6 8 6 10 4 3 6 2 2 2 7 9 9 9 7 2 9 6 2 1 10 4 6 10 4 7 9 6 1 2 2 2 10 8 5 5 10 8 5 1 1 7 3 6 1 5 5 8 2 7 5 10 5 6 4 1 3 1 6 10 10 10 7 1 3 9 6 3 3 5 2 2 5 6 9 4 1 1 9 7 7 6 2 2 7 3 2 1 5 4 7 3 7 5 3...

output:

479745590

result:

ok answer is '479745590'

Test #104:

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

input:

5000 10
8 3 8 10 6 5 5 1 9 2 1 9 4 4 4 6 8 1 1 3 4 3 6 3 7 8 5 1 8 3 4 8 5 1 9 5 10 1 10 10 10 9 5 4 7 5 6 1 9 5 9 9 7 8 9 4 7 6 3 8 3 4 6 8 3 3 5 3 7 1 9 1 4 1 8 3 1 5 2 6 2 6 2 2 2 8 5 4 5 1 3 1 9 1 7 10 2 6 1 4 1 8 5 7 9 8 3 1 3 5 5 6 4 5 2 7 3 2 9 9 7 8 2 2 1 1 8 8 7 4 2 5 7 2 2 7 9 1 2 1 5 3 9 ...

output:

566346851

result:

ok answer is '566346851'

Test #105:

score: 0
Accepted
time: 5ms
memory: 17748kb

input:

5000 10
3 1 3 9 10 9 8 5 2 7 6 7 7 10 9 3 7 4 6 3 2 6 3 4 3 3 10 1 8 5 3 2 3 1 10 1 3 1 4 2 8 10 7 2 9 2 5 6 5 1 7 6 9 8 6 4 9 5 10 10 10 6 9 10 2 7 6 4 1 9 7 6 2 1 6 3 2 3 5 4 1 8 8 3 1 8 7 9 3 3 10 5 3 9 9 5 7 2 5 4 4 8 9 10 9 6 1 2 2 2 6 8 7 1 10 3 3 3 6 7 3 9 8 1 2 2 8 7 10 10 1 4 1 2 10 7 7 6 2...

output:

660919340

result:

ok answer is '660919340'

Test #106:

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

input:

5000 20
10 19 3 10 16 10 19 10 18 18 10 3 10 10 10 10 3 10 10 10 15 10 18 10 10 3 19 16 10 3 10 10 12 10 10 18 10 10 15 3 18 5 10 10 15 3 3 10 3 10 3 10 10 3 10 3 10 10 10 15 16 10 18 3 3 3 16 10 3 10 10 3 16 18 10 19 10 10 14 3 10 10 10 3 18 10 10 3 10 19 10 10 10 16 3 15 10 10 10 15 10 3 10 3 10 1...

output:

496138525

result:

ok answer is '496138525'

Test #107:

score: 0
Accepted
time: 5ms
memory: 19412kb

input:

5000 20
2 4 4 6 2 4 20 2 4 3 4 2 3 2 2 5 3 6 2 4 5 6 2 3 4 4 6 20 4 2 6 2 2 6 2 3 5 20 2 5 3 2 2 2 3 3 6 5 2 2 4 4 2 4 4 2 6 2 4 6 3 6 2 4 3 6 4 20 2 4 6 3 6 5 4 2 3 4 2 2 4 5 2 6 4 3 4 4 2 2 4 6 2 6 2 4 13 2 4 2 4 2 4 4 5 4 10 13 6 4 4 4 2 2 20 6 6 2 2 2 2 4 9 2 6 4 2 5 2 4 2 2 2 13 4 4 2 2 4 4 2 2...

output:

540885700

result:

ok answer is '540885700'

Test #108:

score: 0
Accepted
time: 10ms
memory: 16564kb

input:

5000 20
5 18 10 16 10 19 11 16 14 17 10 4 19 8 2 7 4 10 19 6 17 6 13 18 4 2 20 11 5 10 19 5 1 18 19 20 12 12 1 19 18 19 13 1 15 20 15 7 13 12 18 19 20 9 10 14 16 13 10 19 19 10 19 14 18 8 15 9 19 13 11 1 20 11 12 10 16 7 15 2 14 1 16 16 15 9 20 16 17 18 10 6 8 8 17 6 14 2 9 16 6 6 15 6 2 3 18 19 20 ...

output:

917648821

result:

ok answer is '917648821'

Test #109:

score: 0
Accepted
time: 10ms
memory: 18768kb

input:

5000 20
13 8 1 10 3 16 20 9 19 16 6 14 13 18 12 3 13 10 18 12 8 17 16 3 16 9 9 4 3 4 3 7 16 3 6 8 15 14 7 18 10 11 19 12 20 3 1 8 9 4 15 15 4 12 20 5 1 13 2 8 9 5 11 2 13 19 15 19 6 17 3 5 13 6 9 7 17 20 14 14 7 13 12 20 19 10 19 18 16 13 10 18 9 16 3 11 13 4 16 15 16 17 5 20 4 16 17 5 9 11 1 13 9 1...

output:

508032089

result:

ok answer is '508032089'

Test #110:

score: 0
Accepted
time: 7ms
memory: 19212kb

input:

5000 20
18 7 17 11 14 12 13 1 16 2 15 2 18 1 18 15 16 3 15 15 16 20 18 9 15 12 11 17 2 16 12 2 4 4 9 11 19 18 6 18 7 1 4 6 17 10 17 12 17 9 7 13 18 18 11 2 13 7 14 17 7 20 2 13 11 15 13 8 10 6 9 9 16 2 14 11 7 5 6 15 1 11 12 3 8 16 2 19 15 7 17 11 18 13 5 15 3 10 2 12 11 6 19 16 6 4 20 10 2 5 10 19 ...

output:

863945411

result:

ok answer is '863945411'

Test #111:

score: 0
Accepted
time: 11ms
memory: 17880kb

input:

5000 20
19 5 4 2 8 3 6 10 4 4 19 10 3 20 13 9 12 9 18 10 19 6 15 7 4 2 8 8 19 19 4 10 11 13 13 11 16 13 6 6 14 1 5 15 6 20 1 12 19 16 10 8 16 4 19 8 2 8 8 12 2 3 8 2 2 4 8 14 12 17 14 14 4 11 20 2 19 13 10 11 20 19 18 10 16 1 6 5 7 8 12 12 5 20 20 3 9 9 18 10 6 1 13 2 3 14 3 16 10 11 14 8 20 7 12 17...

output:

530822024

result:

ok answer is '530822024'

Test #112:

score: 0
Accepted
time: 20ms
memory: 18660kb

input:

5000 40
9 27 34 32 27 40 34 25 27 32 27 9 34 6 30 29 27 40 6 9 9 29 27 9 16 32 27 27 9 9 12 32 12 6 27 6 6 9 40 12 12 27 32 6 34 40 9 12 1 12 27 6 40 40 27 29 6 27 32 9 29 27 40 6 27 27 27 9 9 27 27 34 6 9 34 27 34 12 12 34 9 32 27 27 16 12 32 25 9 29 9 12 6 27 12 34 9 12 27 6 32 9 27 12 27 27 27 9 ...

output:

382372668

result:

ok answer is '382372668'

Test #113:

score: 0
Accepted
time: 23ms
memory: 18044kb

input:

5000 40
33 17 36 33 38 7 33 30 11 33 33 30 30 7 11 19 38 30 7 33 30 36 30 33 36 36 7 30 33 33 18 30 33 11 16 7 36 33 36 30 11 38 11 7 30 33 7 7 16 11 36 36 33 18 20 36 18 33 38 18 30 36 33 7 36 36 38 30 33 33 5 17 36 33 38 33 30 36 30 36 38 33 33 33 30 30 33 36 7 36 38 30 9 19 19 33 16 36 33 36 30 1...

output:

676726804

result:

ok answer is '676726804'

Test #114:

score: 0
Accepted
time: 31ms
memory: 17912kb

input:

5000 40
13 9 31 24 4 33 30 36 6 23 29 14 11 10 8 30 2 31 30 20 39 4 24 13 36 13 14 14 33 38 15 26 25 2 39 2 22 8 19 18 34 25 2 24 21 5 2 20 8 21 28 20 37 22 33 27 38 39 34 18 16 35 32 28 38 11 19 28 8 33 21 8 16 5 14 40 29 37 24 14 31 13 31 34 25 19 11 16 8 6 39 28 18 17 9 23 29 17 19 34 4 38 1 37 2...

output:

534255931

result:

ok answer is '534255931'

Test #115:

score: 0
Accepted
time: 34ms
memory: 16520kb

input:

5000 40
34 38 40 18 34 35 27 19 17 22 7 17 16 24 39 4 25 25 10 13 7 34 33 20 21 23 15 37 35 39 25 3 37 4 3 6 15 34 5 17 23 2 37 24 11 10 10 8 20 20 25 31 8 12 17 6 18 39 11 14 3 10 30 12 19 34 22 24 5 40 37 12 1 36 37 21 9 16 5 3 13 26 15 29 1 39 11 1 15 6 21 18 19 26 18 37 33 4 17 6 40 5 34 26 36 2...

output:

140024597

result:

ok answer is '140024597'

Test #116:

score: 0
Accepted
time: 34ms
memory: 16480kb

input:

5000 40
5 21 17 26 18 40 14 35 15 26 19 25 38 38 39 19 14 11 34 39 20 25 14 4 25 5 14 36 1 34 18 14 5 9 18 32 2 12 8 32 19 6 38 35 32 34 31 1 21 18 40 8 29 39 7 4 29 6 21 9 32 24 31 23 33 9 9 14 27 32 14 30 28 17 36 36 17 32 6 21 34 29 39 18 20 7 13 16 36 37 40 13 12 22 26 33 31 34 1 17 2 15 40 19 1...

output:

238266717

result:

ok answer is '238266717'

Test #117:

score: 0
Accepted
time: 30ms
memory: 18484kb

input:

5000 40
3 40 6 4 36 22 33 30 34 31 6 19 29 24 4 39 18 37 35 19 28 22 30 31 29 25 23 38 25 16 5 10 37 17 6 33 34 21 39 6 23 4 12 32 37 27 11 1 18 31 34 40 22 12 33 24 5 36 35 36 4 31 17 30 19 15 30 26 28 30 10 25 3 26 27 14 26 28 30 19 12 40 11 20 1 24 33 4 35 22 21 14 27 28 1 2 20 40 13 3 28 40 39 3...

output:

143027165

result:

ok answer is '143027165'

Test #118:

score: 0
Accepted
time: 38ms
memory: 18028kb

input:

5000 50
12 49 1 47 49 3 1 3 49 3 26 26 26 49 39 13 38 13 7 31 3 3 3 39 3 3 3 26 33 12 33 49 13 49 49 47 13 3 26 39 33 31 31 31 13 13 12 33 3 47 39 33 13 33 13 49 12 3 31 39 13 3 12 26 3 33 3 33 3 49 3 49 26 3 33 3 26 26 39 13 39 47 33 50 33 3 26 35 3 3 1 13 49 1 33 33 39 33 23 3 15 1 26 13 22 13 13 ...

output:

343682503

result:

ok answer is '343682503'

Test #119:

score: 0
Accepted
time: 36ms
memory: 17624kb

input:

5000 50
32 37 44 44 32 23 37 3 11 32 32 24 23 11 32 23 32 4 37 37 11 37 24 5 7 23 24 11 28 21 3 24 44 23 28 11 23 35 3 32 23 44 11 3 23 23 7 3 32 32 11 32 3 3 23 23 3 23 21 3 32 32 3 38 32 3 32 7 38 24 32 37 24 26 21 23 23 23 32 24 32 49 11 44 23 3 3 3 35 3 3 37 32 11 34 6 38 24 23 3 32 32 28 3 32 2...

output:

879196229

result:

ok answer is '879196229'

Test #120:

score: 0
Accepted
time: 49ms
memory: 18968kb

input:

5000 50
22 28 14 22 5 37 15 32 40 38 43 23 17 26 44 46 18 26 1 2 20 32 27 28 3 5 9 41 40 30 35 10 4 14 26 8 41 9 49 26 17 12 39 46 15 21 8 10 4 48 3 11 13 14 36 31 10 6 28 39 4 37 33 34 30 32 25 20 22 23 15 10 11 7 40 42 46 18 48 30 6 31 14 43 31 41 16 36 41 20 10 35 43 36 44 19 17 7 4 9 36 9 5 28 4...

output:

965037649

result:

ok answer is '965037649'

Test #121:

score: 0
Accepted
time: 49ms
memory: 19500kb

input:

5000 50
37 43 16 34 45 32 30 29 25 25 36 21 15 35 11 48 40 16 3 27 40 10 1 29 36 40 9 25 19 2 5 32 32 11 1 17 14 33 4 2 34 9 28 21 10 40 43 31 22 38 48 34 3 10 24 3 12 18 18 22 41 14 20 35 31 45 29 25 35 29 11 26 11 1 34 31 19 4 43 38 32 2 10 47 14 45 18 28 45 23 31 30 35 18 3 13 30 9 33 29 2 6 49 4...

output:

906760828

result:

ok answer is '906760828'

Test #122:

score: 0
Accepted
time: 53ms
memory: 18864kb

input:

5000 50
1 28 47 4 4 5 33 17 29 22 40 1 35 13 36 15 7 46 33 33 4 36 38 12 43 21 12 38 49 21 15 44 7 9 38 38 25 7 26 10 16 43 18 2 48 3 7 5 5 17 14 12 44 29 2 22 31 33 24 48 32 6 50 26 37 21 24 33 41 8 7 5 6 5 32 31 39 44 38 37 32 48 31 7 28 31 44 8 48 37 17 35 20 10 28 46 37 19 20 2 8 8 21 14 7 29 30...

output:

167467589

result:

ok answer is '167467589'

Test #123:

score: 0
Accepted
time: 53ms
memory: 17992kb

input:

5000 50
40 21 3 21 8 50 20 8 27 26 44 13 2 41 2 38 27 33 27 24 42 5 32 24 15 36 9 4 20 32 19 36 18 29 36 15 43 42 43 42 2 1 46 46 11 22 39 38 48 8 49 19 50 30 28 9 22 2 5 2 7 22 24 23 8 20 18 45 48 21 33 48 21 47 38 29 20 25 34 39 25 3 29 29 10 6 22 49 27 26 5 16 24 32 13 40 33 13 13 26 16 43 27 46 ...

output:

316584235

result:

ok answer is '316584235'

Test #124:

score: -100
Wrong Answer
time: 2ms
memory: 13952kb

input:

200000 5
3 3 3 3 3 3 4 4 3 4 3 4 4 3 3 4 4 3 2 4 3 4 3 4 3 4 4 3 5 3 3 4 3 4 3 3 3 4 3 3 3 3 3 3 3 4 4 4 3 3 3 4 3 3 3 3 3 3 3 3 3 3 3 4 3 4 3 3 3 3 3 3 3 3 4 3 4 4 3 3 3 4 4 3 4 3 3 3 3 3 3 4 3 3 4 3 3 4 4 3 3 3 3 3 3 4 4 3 3 3 3 5 3 4 3 3 4 4 3 3 5 3 3 3 3 4 3 3 3 3 3 3 3 4 3 4 3 4 3 3 3 3 3 3 3 3...

output:

0

result:

wrong answer expected '846189442', found '0'