QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#118591#6627. Line Townyyyyxh6 112ms76636kbC++173.6kb2023-07-03 18:00:452023-07-03 18:00:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-03 18:00:46]
  • 评测
  • 测评结果:6
  • 用时:112ms
  • 内存:76636kb
  • [2023-07-03 18:00:45]
  • 提交

answer

#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int read(){
	char c=getchar();int x=0;bool f=0;
	while(c<48||c>57) f|=(c=='-'),c=getchar();
	do x=(x<<1)+(x<<3)+(c^48),c=getchar();
	while(c>=48&&c<=57);
	if(f) return -x;
	return x;
}
typedef long long ll;
const int N=1000003;
const ll INF=0x3f3f3f3f3f3f3f3f;
int n,a[N];
ll f[2][2][2],g[2][2][2];
void chmn(ll &x,ll v){if(x>v) x=v;}
struct bit{
	int tr[N],stk[N],tp;
	int qry(int x,bool t){
		int res=0;
		for(int i=x;i;i^=(i&-i)) res+=tr[i];
		if(t) return tp-res;
		return res;
	}
	void upd(int x){
		stk[++tp]=x;
		for(int i=x;i<=n;i+=(i&-i)) ++tr[i];
	}
	void clear(){
		while(tp){
			for(int i=stk[tp--];i<=n;i+=(i&-i))
				if(tr[i]) tr[i]=0;
				else break;
		}
	}
}F,G;
int buc[N],rk;
vector<int> v[N][2];
int seq[N];
int main(){
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=n;++i) if(i&1) a[i]=-a[i];
	for(int i=1;i<=n;++i) buc[++rk]=abs(a[i]);
	sort(buc+1,buc+rk+1);rk=unique(buc+1,buc+rk+1)-buc-1;
	for(int i=1;i<=n;++i)
		if(a[i]<0) v[lower_bound(buc+1,buc+rk+1,-a[i])-buc][1].emplace_back(i);
		else v[lower_bound(buc+1,buc+rk+1,a[i])-buc][0].emplace_back(i);
	for(int t=0;t<2;++t)
		for(int x=0;x<2;++x)
			for(int y=0;y<2;++y) f[t][x][y]=INF;
	if(buc[1]) f[1][0][0]=f[0][1][1]=0;
	else{
		int len=v[1][0].size();
		for(int x:v[1][0]) F.upd(x);
		for(int i=0;i<=len;++i){
			f[~i&1][i&1][(len^i)&1]=0;
			f[i&1][~i&1][~(len^i)&1]=0;
		}
	}
	for(int pos=1;pos<=rk;++pos){
		if(!buc[pos]) continue;
		int len=v[pos][0].size()+v[pos][1].size();
		for(int t=0;t<2;++t)
			for(int x=0;x<2;++x)
				for(int y=0;y<2;++y)
					g[t][x][y]=f[t][x][y],f[t][x][y]=INF;
		for(int t=0;t<2;++t)
			for(int x=0;x<2;++x)
				for(int y=0;y<2;++y){
					if(g[t][x][y]==INF) continue;
					if(x!=y){
						int o[2]={0,0};
						ll cur=0;
						for(int i=0,par=y;i<len;++i,par^=1){
							if(o[par]>=int(v[pos][par].size())) goto nxt;
							seq[i]=v[pos][par][o[par]++];
							cur+=F.qry(seq[i],1)+G.qry(seq[i],1);
							G.upd(seq[i]);
						}
						if(o[0]<int(v[pos][0].size())||o[1]<int(v[pos][1].size())) goto nxt;
						chmn(f[t][x][y^(len&1)],g[t][x][y]+cur);
						for(int i=0;i+1<len;i+=2){
							cur-=F.qry(seq[i],1);
							cur-=F.qry(seq[i+1],1);
							cur+=F.qry(seq[i],0);
							cur+=F.qry(seq[i+1],0);
							chmn(f[t][x][y^(len&1)],g[t][x][y]+cur);
						}
						nxt: G.clear();
					}
					else{
						for(int tt=0;tt<2;++tt){
							int o[2]={0,0};
							ll cur=0;
							if(tt){
								if(v[pos][x].empty()) goto jump;
								seq[0]=v[pos][x][o[x]++];
								cur+=F.qry(seq[0],0);
								G.upd(seq[0]);
							}
							for(int i=tt,par=y;i<len;++i,par^=1){
								if(o[par]>=int(v[pos][par].size())) goto jump;
								seq[i]=v[pos][par][o[par]++];
								cur+=F.qry(seq[i],1)+G.qry(seq[i],1);
								G.upd(seq[i]);
							}
							if(o[0]<int(v[pos][0].size())||o[1]<int(v[pos][1].size())) goto jump;
							chmn(f[t^tt][x^tt][y^(len&1)^tt],g[t][x][y]+cur);
							for(int i=tt;i+1<len;i+=2){
								if(seq[i]>seq[i+1]) --cur;else ++cur;
								swap(seq[i],seq[i+1]);
								cur-=F.qry(seq[i],1);
								cur-=F.qry(seq[i+1],1);
								cur+=F.qry(seq[i],0);
								cur+=F.qry(seq[i+1],0);
								chmn(f[t^tt][x^tt][y^(len&1)^tt],g[t][x][y]+cur);
							}
							jump: G.clear();
						}
					}
				}
		for(int x:v[pos][0]) F.upd(x);
		for(int x:v[pos][1]) F.upd(x);
	}
	ll res=INF;
	for(int x=0;x<2;++x)
		for(int y=0;y<2;++y) chmn(res,f[0][x][y]);
	if(res==INF) puts("-1");
	else printf("%lld\n",res);
	return 0;
}

详细

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 4ms
memory: 58140kb

input:

10
1 1 1 1 1 -1 -1 -1 1 -1

output:

-1

result:

ok 1 number(s): "-1"

Test #2:

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

input:

10
1 1 1 1 1 1 -1 1 1 -1

output:

3

result:

ok 1 number(s): "3"

Test #3:

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

input:

1
-1

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 12ms
memory: 58236kb

input:

2000
1 -1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 ...

output:

15146

result:

ok 1 number(s): "15146"

Test #5:

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

input:

2000
-1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 1 1 -1 1 1 1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 1 1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 1 -1 1 1 -1 -1 -1 ...

output:

24933

result:

ok 1 number(s): "24933"

Test #6:

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

input:

2000
1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 1 1 -1 1 1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 1 1 1 1 -1 1 1 1 1 -1 -1 1 1 1 -1 1 1 1 1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 1 -...

output:

18090

result:

ok 1 number(s): "18090"

Test #7:

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

input:

2000
-1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 1 -1 -1 1 1 1...

output:

-1

result:

ok 1 number(s): "-1"

Test #8:

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

input:

2000
-1 1 -1 1 1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 ...

output:

9973

result:

ok 1 number(s): "9973"

Test #9:

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

input:

2000
-1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 ...

output:

499500

result:

ok 1 number(s): "499500"

Test #10:

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

input:

2000
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

499500

result:

ok 1 number(s): "499500"

Test #11:

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

input:

1999
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

499500

result:

ok 1 number(s): "499500"

Test #12:

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

input:

1997
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

498501

result:

ok 1 number(s): "498501"

Test #13:

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

input:

2000
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

-1

result:

ok 1 number(s): "-1"

Subtask #2:

score: 3
Accepted

Dependency #1:

100%
Accepted

Test #14:

score: 3
Accepted
time: 6ms
memory: 58300kb

input:

1
1

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: 0
Accepted
time: 111ms
memory: 75972kb

input:

500000
1 -1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 1 1 -1 -1 1 -1 1 1 1 1 1 -1 -1 -1 1 -1 1 1 1 1 1 1 1 -1 -1 1 1 -1 1 1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 1 1 -1 1 1 1 1 1 1 1 1 1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 1 -1 1 -1 -1 1 1 -1 1 1 1 1 -1 1 1 -1 -1 1 ...

output:

29737766

result:

ok 1 number(s): "29737766"

Test #16:

score: 0
Accepted
time: 104ms
memory: 74700kb

input:

500000
1 -1 -1 1 1 1 1 1 1 1 1 1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 1 1 -1 1 -1 1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1...

output:

66957355

result:

ok 1 number(s): "66957355"

Test #17:

score: 0
Accepted
time: 95ms
memory: 74116kb

input:

500000
1 -1 1 1 1 -1 1 1 -1 1 1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 1 -1 1 1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1...

output:

50480873

result:

ok 1 number(s): "50480873"

Test #18:

score: 0
Accepted
time: 105ms
memory: 75288kb

input:

500000
-1 1 1 -1 1 1 -1 1 1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 1 1 1 -1 1 1 -1 1 1 -1 1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 1 1 1 -1 1 -1 1 -1 1 1 1 1 1 -1 1 -1 1 1 1 -1 -1 -1 -1...

output:

-1

result:

ok 1 number(s): "-1"

Test #19:

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

input:

500000
1 1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 1 -1 1 1 1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 1...

output:

90473670

result:

ok 1 number(s): "90473670"

Test #20:

score: 0
Accepted
time: 71ms
memory: 74424kb

input:

500000
-1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

31249875000

result:

ok 1 number(s): "31249875000"

Test #21:

score: 0
Accepted
time: 76ms
memory: 73900kb

input:

500000
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -...

output:

31249875000

result:

ok 1 number(s): "31249875000"

Test #22:

score: 0
Accepted
time: 78ms
memory: 76636kb

input:

499999
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -...

output:

31249875000

result:

ok 1 number(s): "31249875000"

Test #23:

score: 0
Accepted
time: 71ms
memory: 73772kb

input:

499997
-1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

31249375003

result:

ok 1 number(s): "31249375003"

Test #24:

score: 0
Accepted
time: 56ms
memory: 73628kb

input:

500000
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -...

output:

-1

result:

ok 1 number(s): "-1"

Subtask #3:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #25:

score: 3
Accepted
time: 3ms
memory: 60316kb

input:

10
0 1 0 0 1 1 -1 0 1 -1

output:

9

result:

ok 1 number(s): "9"

Test #26:

score: 0
Accepted
time: 15ms
memory: 58308kb

input:

10
-1 1 0 0 1 0 -1 0 1 -1

output:

10

result:

ok 1 number(s): "10"

Test #27:

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

input:

1
0

output:

0

result:

ok 1 number(s): "0"

Test #28:

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

input:

2000
0 1 -1 -1 1 1 0 1 0 -1 0 0 0 1 0 -1 1 0 -1 1 1 0 0 1 0 -1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 -1 -1 -1 -1 0 0 0 0 0 1 -1 0 0 0 1 -1 0 0 -1 0 -1 0 1 1 -1 0 -1 0 -1 0 0 -1 1 1 -1 0 0 0 0 -1 -1 1 -1 0 0 0 0 0 -1 0 -1 1 0 0 0 1 0 0 1 1 0 0 0 0 0 1 -1 0 -1 1 1 1 1 0 1 1 0 0 1 0 1 0 -1 -1 0 0 -1 -1...

output:

252956

result:

ok 1 number(s): "252956"

Test #29:

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

input:

2000
1 0 1 -1 -1 1 -1 0 -1 0 -1 1 0 0 -1 1 0 0 -1 0 0 0 -1 -1 0 0 0 0 0 -1 0 0 0 1 0 0 -1 1 1 1 0 1 1 1 0 -1 -1 1 1 1 1 0 -1 1 0 1 0 0 0 0 -1 1 -1 -1 -1 0 0 0 -1 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 -1 0 0 0 -1 0 0 -1 0 -1 0 -1 0 0 1 -1 1 0 0 0 0 0 1 0 0 -1 0 1 0 0 1 1 -1 1 0 0 0 0 -1 0 -1 0 -1 0 0...

output:

262836

result:

ok 1 number(s): "262836"

Test #30:

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

input:

2000
-1 1 1 0 0 0 0 1 0 -1 1 -1 1 0 1 0 1 0 0 1 0 0 -1 -1 0 0 1 0 1 0 -1 0 0 0 0 0 1 0 1 -1 1 0 -1 -1 1 0 -1 0 1 1 -1 0 -1 0 0 -1 1 1 0 -1 -1 0 -1 0 0 0 1 0 -1 -1 -1 0 -1 0 1 1 0 -1 0 -1 1 0 -1 0 -1 1 0 0 1 -1 0 0 0 0 0 0 0 0 -1 0 0 -1 0 -1 1 0 0 0 0 -1 0 1 0 -1 -1 1 -1 0 0 1 -1 -1 -1 1 1 0 -1 0 0 0...

output:

259619

result:

ok 1 number(s): "259619"

Test #31:

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

input:

2000
-1 -1 1 0 0 0 -1 0 0 -1 -1 0 -1 0 -1 0 1 0 0 1 0 0 0 -1 0 0 -1 1 0 1 0 -1 1 -1 -1 -1 -1 0 0 1 0 0 0 -1 0 -1 0 0 1 -1 0 0 0 1 0 0 0 1 0 0 0 1 0 -1 -1 0 1 0 1 -1 -1 -1 1 1 0 1 -1 -1 0 1 0 0 0 0 0 0 -1 -1 0 -1 -1 0 -1 -1 1 1 1 -1 1 0 0 0 1 -1 -1 0 -1 -1 0 0 0 -1 0 1 0 0 0 0 0 -1 0 0 -1 0 -1 0 -1 -...

output:

-1

result:

ok 1 number(s): "-1"

Test #32:

score: -3
Wrong Answer
time: 3ms
memory: 60296kb

input:

1999
-1 1 1 0 -1 -1 0 1 0 0 1 0 -1 1 -1 1 0 1 1 -1 1 -1 -1 0 1 -1 -1 1 0 1 -1 0 -1 -1 -1 -1 1 0 -1 0 -1 1 -1 1 1 0 -1 -1 -1 0 0 1 -1 0 -1 1 1 -1 1 -1 -1 -1 1 1 0 0 0 1 -1 -1 1 1 0 0 1 -1 -1 0 -1 1 -1 1 -1 0 0 -1 0 0 1 -1 0 0 0 1 -1 -1 1 -1 -1 1 0 1 1 1 -1 -1 1 1 0 1 1 1 0 -1 -1 0 -1 0 0 1 1 0 -1 -1 ...

output:

216719

result:

wrong answer 1st numbers differ - expected: '216714', found: '216719'

Subtask #4:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #44:

score: 0
Wrong Answer
time: 49ms
memory: 75620kb

input:

500000
1 1 -1 0 0 -1 1 -1 0 0 1 1 -1 -1 -1 1 -1 1 0 0 -1 1 1 0 0 0 0 0 1 0 -1 0 -1 1 1 0 0 -1 1 0 0 0 0 0 -1 0 0 -1 1 1 0 0 1 0 0 1 -1 0 1 0 0 0 0 -1 1 0 1 0 -1 0 -1 1 1 0 -1 0 0 0 0 0 0 1 -1 1 -1 1 0 1 -1 0 1 -1 0 -1 -1 1 1 0 1 0 -1 0 0 0 -1 0 -1 0 0 1 -1 1 0 0 1 0 1 0 1 0 0 -1 0 1 1 -1 -1 0 0 -1 -...

output:

15602273164

result:

wrong answer 1st numbers differ - expected: '15602272809', found: '15602273164'

Subtask #5:

score: 0
Wrong Answer

Test #60:

score: 4
Accepted
time: 3ms
memory: 60148kb

input:

10
3 10 5 -9 7 2 -6 1 8 0

output:

-1

result:

ok 1 number(s): "-1"

Test #61:

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

input:

10
-9 0 -1 7 5 10 6 3 2 -8

output:

13

result:

ok 1 number(s): "13"

Test #62:

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

input:

2000
40667 -598150 -1084780 1201651 1570514 -1859539 -2029075 2941581 -2945945 3038404 3447919 5293872 -5335692 -5669647 5973784 6041345 6346915 -7222112 8820986 -9153143 9563103 9749206 -9894732 -11847193 11987150 12161864 13336572 13528051 -13722732 -13836176 -15497141 -15841563 15862227 16618123 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #63:

score: -4
Wrong Answer
time: 4ms
memory: 56264kb

input:

2000
3038404 -798315545 693574695 172661079 516504064 164016456 193562146 -131746730 382134316 -398886978 188767854 -834289064 -965673210 -826409444 -281381674 450991903 -592752625 81651101 -594873306 -352059270 -651772982 540062674 -769881300 68999588 307151563 -129950325 550154987 354801227 840540...

output:

988633

result:

wrong answer 1st numbers differ - expected: '658039', found: '988633'

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%