QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#24584#2361. BulldozerMr_EightAC ✓49ms13092kbC++203.1kb2022-04-01 10:34:112022-04-30 06:15:00

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 06:15:00]
  • Judged
  • Verdict: AC
  • Time: 49ms
  • Memory: 13092kb
  • [2022-04-01 10:34:11]
  • Submitted

answer

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/priority_queue.hpp>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
#define vi vector<int>
#define ull unsigned long long
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
using namespace std;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
	template<class T>
	inline void read(T &x) {
		x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		if(fu)x=-x;
	}
	inline int read() {
		int x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		return fu?-x:x;
	}
	template<class T,class... Args>
	inline void read(T& t,Args&... args) {
		read(t);
		read(args...);
	}
	char _n_u_m_[40];
	template<class T>
	inline void write(T x) {
		if(x==0){
			putchar('0');
			return;
		}
		T tmp = x > 0 ? x : -x ;
		if( x < 0 ) putchar('-') ;
		register int cnt = 0 ;
		while( tmp > 0 ) {
			_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
			tmp /= 10 ;
		}
		while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
	}
	template<class T>
	inline void write(T x ,char ch) {
		write(x);
		putchar(ch);
	}
}
using namespace fastIO;
ll a[200002],pre[200002],suf[200002],t[200002],dp[200002],ans=1e18,n,c[200002];
inline void add(int pos,ll v){
	while(pos<=n){
		c[pos]=min(c[pos],v);
		pos+=(-pos&pos);
	}
}
inline ll query(int pos){
	ll rt=2000000000000000000ll;
	while(pos){
		rt=min(rt,c[pos]);
		pos-=(-pos&pos);
	}
	return rt;
}
inline void ins(int pos){
	add(lower_bound(t+1,t+n+1,pre[pos])-t,-2*pre[pos]+dp[pos]-pos);
}
inline void orz(int i){
	dp[i]=query(upper_bound(t+1,t+n+1,pre[i])-t-1)+pre[i]*2+i-1;//if(i==9)cerr<<dp[i]<<"K";
	if(a[i]<=0)dp[i]=min(dp[i],dp[i-1]);
	if(pre[i]>=0)dp[i]=min(dp[i],pre[i]+i-1);
	if(suf[i+1]>=0)ans=min(ans,dp[i]+max(0ll,n-i+suf[i+1]-1));
	if(i!=n)ins(i);
}
int main() {
	cin>>n;
	F(i,1,n)a[i]=read()-1;
	F(i,1,n)pre[i]=pre[i-1]+a[i];
	UF(i,n,1)suf[i]=suf[i+1]+a[i];
	if(pre[n]>=0)ans=n+pre[n]-1;
	memset(dp,0x3f,sizeof(dp));
	memset(c,0x3f,sizeof(c));
	dp[0]=0;
	F(i,1,n)t[i]=pre[i-1];
	sort(t+1,t+n+1);
	ins(0);
	F(i,1,n){
		orz(i);//cerr<<lower_bound(t+1,t+n+1,pre[i])-t<<" "<<dp[i]<<" "<<ans<<endl;
	}
	cout<<ans;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 11992kb

input:

9
10 0 1 5 2 0 0 1 0

output:

16

result:

ok single line: '16'

Test #2:

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

input:

7
1 0 0 4 0 0 1

output:

3

result:

ok single line: '3'

Test #3:

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

input:

7
6 0 1 5 2 0 1

output:

12

result:

ok single line: '12'

Test #4:

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

input:

10
0 10 0 1 0 0 1 0 0 2

output:

10

result:

ok single line: '10'

Test #5:

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

input:

10
3 0 2 0 2 3 0 20 4 5

output:

35

result:

ok single line: '35'

Test #6:

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

input:

1
847106130

output:

847106129

result:

ok single line: '847106129'

Test #7:

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

input:

1
0

output:

0

result:

ok single line: '0'

Test #8:

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

input:

7
6 0 4 8 7 6 4

output:

33

result:

ok single line: '33'

Test #9:

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

input:

3
9 1 4

output:

11

result:

ok single line: '11'

Test #10:

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

input:

1
1

output:

0

result:

ok single line: '0'

Test #11:

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

input:

4
9 8 2 5

output:

22

result:

ok single line: '22'

Test #12:

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

input:

4
4 1 6 7

output:

15

result:

ok single line: '15'

Test #13:

score: 0
Accepted
time: 22ms
memory: 12600kb

input:

149790
0 6 7 9 0 3 7 7 4 10 2 0 8 7 5 1 3 5 0 6 2 9 5 6 6 4 10 4 7 2 10 4 10 5 2 7 3 7 9 6 0 9 0 3 2 3 4 8 5 3 5 10 8 7 6 7 1 10 9 5 8 2 3 6 3 0 0 7 4 9 10 1 8 1 2 6 9 5 9 2 1 1 7 2 3 5 6 6 7 3 10 4 2 9 8 2 1 4 7 4 2 10 10 2 2 7 5 5 6 3 0 8 0 5 5 3 1 4 7 6 9 2 6 7 10 3 8 4 8 7 9 7 1 2 7 10 7 6 2 6 8...

output:

747427

result:

ok single line: '747427'

Test #14:

score: 0
Accepted
time: 24ms
memory: 12408kb

input:

118589
8 7 7 8 9 3 2 8 7 10 9 2 1 7 4 2 1 8 10 0 9 6 7 10 9 10 2 9 0 8 1 0 0 3 3 9 0 7 5 7 9 3 8 3 10 4 7 0 10 1 7 10 4 6 8 1 4 5 3 8 4 0 1 9 1 6 1 4 6 1 0 10 0 3 3 0 7 6 6 6 1 9 10 3 10 4 5 1 4 5 0 6 1 2 3 1 0 0 7 7 2 10 8 3 7 8 3 2 6 10 6 1 6 6 3 0 4 9 4 0 3 2 6 9 10 9 1 0 2 3 7 4 0 9 5 4 6 1 1 1 ...

output:

593270

result:

ok single line: '593270'

Test #15:

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

input:

124406
4 10 8 10 5 2 6 0 5 7 4 10 7 9 3 8 0 10 9 2 7 5 2 5 3 0 9 3 1 8 10 5 10 6 1 0 0 10 8 3 1 6 7 1 10 6 2 8 5 9 8 2 0 8 2 8 1 6 9 6 10 9 7 7 9 6 8 0 10 1 3 10 4 5 5 6 10 4 1 4 3 5 5 5 8 9 8 2 0 6 6 0 8 0 3 10 6 0 6 3 9 1 8 3 2 1 4 0 6 4 7 5 9 10 0 8 7 5 3 5 4 7 7 7 3 2 7 8 5 2 3 3 9 0 4 5 2 3 0 8...

output:

621380

result:

ok single line: '621380'

Test #16:

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

input:

54783
763 34165 48233 2370 10355 15659 1106 3601 44652 9650 45532 24070 15709 7676 22156 30561 46412 23313 18388 25708 17256 22566 14982 13524 23276 20537 14640 20030 47619 33513 27555 15164 37824 29854 27516 32087 5174 30219 37007 23590 28790 37330 20654 45483 42308 29529 26548 4314 32129 1228 1282...

output:

1366033193

result:

ok single line: '1366033193'

Test #17:

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

input:

94772
503823899 515912189 305944949 447699478 243357877 479704103 6285241 439714165 917122217 706206253 763432001 277943853 255398793 681821686 238832484 10875257 318468992 324316952 875004196 359771530 715879854 152418205 798234969 646508477 332976201 23817471 847442139 236599734 647242476 27220000...

output:

47413562342832

result:

ok single line: '47413562342832'

Test #18:

score: 0
Accepted
time: 25ms
memory: 12896kb

input:

200000
1 0 3 0 0 10 1 0 2 0 0 0 2 4 0 0 6 3 10 0 2 0 0 0 0 0 0 0 0 10 6 3 10 1 2 10 9 0 0 4 0 1 0 0 9 0 0 4 0 0 3 0 10 0 3 9 7 0 0 8 0 0 0 0 0 1 4 10 2 0 0 0 0 9 6 0 2 0 0 1 2 7 0 10 0 0 0 0 0 0 0 9 0 0 0 0 6 0 0 9 1 3 9 1 3 10 4 0 9 8 4 5 0 2 2 9 9 0 0 7 0 0 9 9 1 0 0 0 5 6 0 10 9 0 5 6 0 0 0 0 0 0...

output:

1509133

result:

ok single line: '1509133'

Test #19:

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

input:

200000
0 0 4 0 0 0 1 0 1 5 10 0 0 0 7 6 2 0 4 1 0 5 0 0 5 0 0 0 0 0 0 9 0 0 8 3 3 0 2 0 6 8 0 0 1 0 1 1 0 0 9 0 5 6 0 8 0 0 0 0 9 4 0 5 6 0 0 0 10 7 0 9 8 0 7 0 10 10 0 8 10 2 0 6 4 0 0 9 0 0 0 6 0 6 0 8 0 0 0 10 4 3 0 2 0 0 9 1 8 0 0 0 6 3 0 0 0 0 1 5 0 0 9 0 0 4 0 0 0 2 0 0 6 0 3 0 3 0 5 0 0 9 0 3...

output:

1166702

result:

ok single line: '1166702'

Test #20:

score: 0
Accepted
time: 39ms
memory: 12964kb

input:

200000
3 0 0 3 0 0 6 0 1 0 5 0 3 10 8 0 3 10 0 0 5 0 10 0 0 1 2 9 0 3 0 6 8 0 4 7 1 0 2 0 0 0 0 10 0 0 0 8 2 0 0 0 5 0 0 7 5 5 0 8 0 0 1 0 0 2 0 0 0 0 7 0 0 0 0 0 0 8 0 0 8 5 0 8 10 0 0 0 0 4 2 9 6 0 0 10 1 3 0 0 0 0 1 0 4 6 0 1 0 7 0 4 7 0 7 0 0 3 10 0 0 10 0 6 10 0 6 4 6 0 4 1 9 1 10 0 0 6 10 0 9 ...

output:

1012315670

result:

ok single line: '1012315670'

Test #21:

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

input:

200000
6 0 0 5 3 0 0 6 0 0 3 6 8 6 0 1 0 1 10 8 7 6 3 0 8 3 4 7 0 3 0 9 0 2 5 0 0 0 0 7 0 0 1 0 0 0 0 0 8 2 1 0 5 7 0 6 0 9 0 4 7 0 0 0 0 9 7 10 0 0 0 0 0 7 0 4 0 0 5 0 6 0 0 1 10 0 2 8 0 9 4 8 7 0 0 9 0 3 2 0 2 4 0 3 0 0 0 7 8 0 3 0 2 9 8 0 0 0 8 10 9 2 6 3 0 2 0 7 8 0 0 0 6 3 0 0 0 9 0 0 4 5 0 0 4...

output:

805272023

result:

ok single line: '805272023'

Test #22:

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

input:

200000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 8 0 0 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 9 151915 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

843281

result:

ok single line: '843281'

Test #23:

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

input:

200000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 7 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

1485943

result:

ok single line: '1485943'

Test #24:

score: 0
Accepted
time: 35ms
memory: 13016kb

input:

200000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 25ms
memory: 12960kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

0

result:

ok single line: '0'

Test #26:

score: 0
Accepted
time: 27ms
memory: 12960kb

input:

200000
0 1 0 0 2 0 2 1 2 2 2 1 1 2 0 2 1 1 0 2 1 2 0 1 1 1 1 0 2 1 2 0 0 2 0 1 1 1 0 0 0 0 2 0 0 1 1 2 2 1 2 1 1 2 1 0 2 1 2 0 2 1 2 0 2 1 2 0 1 0 0 1 0 2 2 1 0 0 1 0 0 2 0 2 2 1 1 2 0 2 2 1 1 2 0 1 2 2 0 2 2 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 2 0 0 1 2 1 0 1 2 2 1 2 2 1 1 0 0 1 2 2 2 2 0 1 2 0 0 0 2 2 1...

output:

99894

result:

ok single line: '99894'

Test #27:

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

input:

200000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

199999999999998

result:

ok single line: '199999999999998'

Test #28:

score: 0
Accepted
time: 35ms
memory: 13052kb

input:

200000
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1...

output:

249999

result:

ok single line: '249999'

Test #29:

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

input:

200000
0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0...

output:

233333

result:

ok single line: '233333'

Test #30:

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

input:

200000
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1...

output:

200010

result:

ok single line: '200010'

Test #31:

score: 0
Accepted
time: 25ms
memory: 12912kb

input:

200000
10 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 ...

output:

200019

result:

ok single line: '200019'

Test #32:

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

input:

200000
10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

200019

result:

ok single line: '200019'

Test #33:

score: 0
Accepted
time: 29ms
memory: 12928kb

input:

200000
10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

200019

result:

ok single line: '200019'

Test #34:

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

input:

99999
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10000000...

output:

66665999999998

result:

ok single line: '66665999999998'

Test #35:

score: 0
Accepted
time: 32ms
memory: 12892kb

input:

200000
9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 305618 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48104 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

826425324

result:

ok single line: '826425324'

Test #36:

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

input:

8
0 3 3 0 0 2 4 0

output:

9

result:

ok single line: '9'

Test #37:

score: 0
Accepted
time: 29ms
memory: 12940kb

input:

200000
0 1 1 2 5 1 2 0 0 1 1 3 1 1 6 1 0 0 0 0 1 2 0 0 0 14 0 0 4 2 1 0 5 0 0 1 1 0 1 6 3 0 1 3 1 0 4 1 1 0 1 0 0 1 0 0 2 1 0 2 1 3 1 2 6 3 1 0 2 0 1 8 2 0 0 1 1 0 0 1 0 2 0 1 0 2 0 0 0 1 3 0 1 1 0 0 0 0 1 0 0 1 0 2 3 0 1 0 4 3 0 2 3 0 0 2 0 0 1 5 0 0 1 1 0 0 0 2 0 0 0 0 3 0 0 1 1 3 1 0 1 0 2 1 0 1 ...

output:

144223

result:

ok single line: '144223'

Test #38:

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

input:

200000
1 1 1 1 1 0 0 1 0 0 0 0 0 0 1 4 2 0 0 0 0 0 0 3 0 0 1 0 0 0 0 0 0 0 0 0 0 2 3 2 4 1 1 2 0 0 0 0 2 1 0 0 0 1 2 0 0 1 1 3 0 0 1 0 0 0 0 1 0 1 2 1 2 1 1 0 1 3 1 0 1 0 0 0 0 2 0 2 0 1 3 0 0 0 0 0 2 0 1 0 1 0 0 0 2 0 1 4 1 0 0 0 1 3 1 1 2 1 0 0 0 2 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 2 3 0 0 0 0 1 3 0...

output:

66979

result:

ok single line: '66979'

Test #39:

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

input:

200000
9 0 2 1 0 1 0 2 2 0 0 3 4 0 1 0 0 2 1 0 0 0 0 1 6 0 0 2 0 0 1 1 0 0 3 2 0 1 1 1 3 0 1 5 2 0 10 1 0 1 1 0 0 0 1 9 0 2 4 3 0 1 2 1 2 0 10 2 1 0 8 1 0 0 3 2 0 0 1 0 0 0 1 0 0 2 0 0 0 6 1 0 0 2 2 1 0 3 0 1 1 1 1 5 0 0 0 1 0 3 0 0 3 0 4 0 1 1 1 0 12 1 3 3 0 1 1 2 3 1 1 2 1 3 0 0 0 1 2 0 7 9 4 0 0 ...

output:

300007

result:

ok single line: '300007'

Test #40:

score: 0
Accepted
time: 26ms
memory: 12940kb

input:

200000
1 0 1 2 0 0 0 3 0 0 0 1 0 2 1 0 3 0 2 0 0 1 0 0 0 1 2 0 1 0 0 0 1 1 1 0 2 1 3 0 0 1 2 1 1 0 1 0 0 2 0 1 0 0 0 5 0 1 1 1 2 2 1 2 0 4 1 2 0 2 3 0 1 2 2 0 1 0 0 1 0 3 1 0 1 0 1 1 0 1 0 2 3 2 0 0 0 1 0 0 0 0 0 0 2 1 6 3 0 0 0 2 0 1 0 2 0 2 2 1 0 1 2 3 2 1 0 1 2 2 0 0 3 0 1 0 1 0 2 1 4 1 1 0 1 0 0...

output:

111949

result:

ok single line: '111949'

Test #41:

score: 0
Accepted
time: 28ms
memory: 13048kb

input:

200000
2 0 1 0 1 1 0 1 1 1 0 1 2 0 0 0 0 1 1 0 0 3 1 2 0 0 0 1 3 2 1 0 2 2 2 0 3 2 0 2 3 0 0 1 0 1 1 0 1 1 0 1 1 1 1 0 1 2 1 0 1 1 2 0 1 1 2 2 2 1 2 1 1 2 0 1 0 3 0 1 2 0 1 0 1 1 0 1 0 0 2 3 1 2 1 2 0 0 1 0 0 1 1 0 0 0 2 1 0 0 1 2 2 2 0 0 2 2 0 1 0 0 1 0 2 0 0 2 0 0 1 3 1 3 3 3 2 0 1 4 2 1 0 2 0 2 2...

output:

111636

result:

ok single line: '111636'

Test #42:

score: 0
Accepted
time: 24ms
memory: 13092kb

input:

200000
2 0 1 1 2 3 1 0 0 1 1 1 0 1 1 1 1 2 0 0 2 0 1 1 1 0 1 1 0 0 1 1 1 2 1 1 1 0 2 0 0 0 2 2 1 0 1 1 2 1 0 0 1 2 1 0 4 1 1 0 1 0 0 1 2 2 2 1 3 0 1 0 1 3 0 3 2 2 3 2 2 4 1 1 3 2 2 2 0 2 2 1 0 0 1 0 2 0 2 2 0 0 0 1 1 2 3 0 2 0 0 1 2 0 1 1 0 2 1 1 0 1 0 1 3 0 0 2 0 2 0 0 2 1 1 1 1 1 1 0 1 2 3 0 2 2 3...

output:

111902

result:

ok single line: '111902'

Test #43:

score: 0
Accepted
time: 24ms
memory: 12944kb

input:

200000
2 3 0 0 2 0 2 0 0 1 0 0 1 2 1 2 1 0 1 1 2 1 1 1 2 0 2 1 0 1 2 0 1 0 0 1 2 0 1 1 1 0 0 0 1 1 1 2 1 2 0 1 0 1 4 0 1 0 2 1 1 1 0 1 0 0 1 1 0 0 0 2 0 3 1 1 0 0 3 2 3 1 1 1 1 1 2 1 0 1 0 0 0 1 1 2 0 0 2 0 2 2 1 1 1 1 1 0 1 3 2 2 2 3 1 1 0 0 0 1 1 0 1 1 1 1 1 2 1 1 0 1 0 1 1 1 0 1 0 0 1 2 0 0 0 1 0...

output:

111852

result:

ok single line: '111852'