QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#905467#9086. 镜子里的昆虫sunnygreen100 ✓527ms46980kbC++149.7kb2025-02-19 11:43:472025-02-19 11:43:49

Judging History

This is the latest submission verdict.

  • [2025-02-19 11:43:49]
  • Judged
  • Verdict: 100
  • Time: 527ms
  • Memory: 46980kb
  • [2025-02-19 11:43:47]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
int print_precision=10;bool print_T_endl=1;char print_between=' ';
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader;struct Writer;template<size_t id>struct read_tuple{template<typename...T>static void read(Reader&stream,std::tuple<T...>&x){read_tuple<id-1>::read(stream,x);stream>>get<id-1>(x);}};template<>struct read_tuple<0>{template<typename...T>static void read([[maybe_unused]]Reader&stream,[[maybe_unused]]std::tuple<T...>&x){}};template<size_t id>struct print_tuple{template<typename...T>static void print(Writer&stream,const std::tuple<T...>&x){print_tuple<id-1>::print(stream,x);putchar(print_between);stream<<get<id-1>(x);}};template<>struct print_tuple<1>{template<typename...T>static void print(Writer&stream,const std::tuple<T...>&x){stream<<get<0>(x);}};template<>struct print_tuple<0>{template<typename...T>static void print([[maybe_unused]]Writer&stream,[[maybe_unused]]const std::tuple<T...>&x){}};
struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename...T>Reader&operator>>(std::tuple<T...>&x){read_tuple<sizeof...(T)>::read(*this,x);return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}template<typename T1,typename T2>Reader&operator>>(std::pair<T1,T2>&x){*this>>x.first>>x.second;return *this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';
struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(const T&x){for(auto q:x){*this<<q;if(!is_class<decltype(q)>::value)*this<<print_between;}if(!is_class<typename T::value_type>::value&&print_T_endl)*this<<'\n';return *this;}template<typename...T>Writer&operator<<(const std::tuple<T...>&x){print_tuple<sizeof...(T)>::print(*this,x);if(print_T_endl)*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;x+=pow(10,-print_precision)/2;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<print_precision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<print_precision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(const T&c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}template<typename T1,typename T2>Writer&operator<<(const std::pair<T1,T2>&x){*this<<x.first<<print_between<<x.second;if(print_T_endl)*this<<'\n';return *this;}Writer&operator<<(const std::string&str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
#define il inline
#define fi first
#define se second
#define mk make_pair
#define eb emplace_back
#define rep(i,l,r) for(int i=(l); i<=(r); ++i)
#define rep_(i,l,r) for(int i=(l); i>=(r); --i)
typedef long long lr;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
constexpr int mod1=998244353,mod2=1e9+7;
constexpr db pi=3.141592653589793,eps=1e-9;
constexpr int inf32=0x3f3f3f3f,Inf32=0xc0c0c0c0;
constexpr lr inf64=0x3f3f3f3f3f3f3f3f,Inf64=0xc0c0c0c0c0c0c0c0;
template<typename T>il T Max(T x,T y) { return (x>y)? x:y; }
template<typename T>il T Min(T x,T y) { return (x<y)? x:y; }
template<typename T>il T gcd(T x,T y) { return (!y)? x:gcd(y,x%y); }
template<typename T>il T Abs(T x) { return (x>0)? x:(-x); }
template<typename T>il T Rnd(T l,T r,mt19937_64 &eng)
{
	uniform_int_distribution<T> uid(l,r);
	return uid(eng);
}
mt19937_64 eng(chrono::high_resolution_clock::now().time_since_epoch().count());
constexpr int N=100100,M=N*10;
struct BIT
{
	int n,tr[N];
	il void Clear(const int &_) { n=_; rep(i,1,n) tr[i]=0; }
	il void Add(int x) { while(x<=n) ++tr[x],x+=x&(-x); }
	il void Del(int x) { while(x<=n) --tr[x],x+=x&(-x); }
	il int Sum(int x) { int sum=0; while(x) sum+=tr[x],x^=x&(-x); return sum; }
};
BIT bit;

struct node { int l,r,v; };
il bool operator <(const node &X,const node &Y) { return X.l<Y.l; }

struct que { int x,y,z; };
que q[M]; int qcnt,p[M],tmp[M];

using iter=set<node>::iterator;
set<node> odt,st[N<<1];
int pre[N]; set<int> cand;

int n;
il iter Split(const int &x)
{
	iter it=odt.lower_bound((node){x,0,0});
	if(it!=odt.end()&&(it->l)==x) return it;
	--it; int l=it->l,r=it->r,v=it->v;
	st[v].erase((node){l,r,v}),odt.erase((node){l,r,v});
	st[v].insert((node){l,x-1,v}),odt.insert((node){l,x-1,v});
	return st[v].insert((node){x,r,v}),odt.insert((node){x,r,v}).fi;
}
il void Modify(const int &l,const int &r,const int &x)
{
	iter R=Split(r+1),L=Split(l),it,it2;
	for(it=L; it!=R; ++it)
	{
		cand.insert(it->l),it2=st[it->v].upper_bound((node){it->l,0,0});
		if(it2!=st[it->v].end()) cand.insert(it2->l);
		st[it->v].erase((node){it->l,it->r,it->v});
	}
	odt.erase(L,R),odt.insert((node){l,r,x}),it2=st[x].insert((node){l,r,x}).fi;
	if(next(it2)!=st[x].end()) cand.insert(next(it2)->l);
	int tmp=pre[l];
	(it2==st[x].begin())? pre[l]=0:pre[l]=prev(it2)->r;
	if(pre[l]!=tmp)
		q[++qcnt]=(que){tmp,l,-1},q[++qcnt]=(que){pre[l],l,0};
	cand.erase(cand.begin());
	for(int i:cand)
	{
		tmp=pre[i];
		if(i<=r)
			pre[i]=i-1;
		else
		{
			it=odt.lower_bound((node){i,0,0});
			if((it->l)==i)
			{
				it2=st[it->v].lower_bound((node){it->l,0,0});
				(it2==st[it->v].begin())? pre[i]=0:pre[i]=prev(it2)->r;
			}
			else
				pre[i]=i-1;
		}
		if(pre[i]!=tmp)
			q[++qcnt]=(que){tmp,i,-1},q[++qcnt]=(que){pre[i],i,0};
	}
	cand.clear();
}

int ans[N];
il void cdq(const int &l,const int &r)
{
	if(l==r) return;
	int mid=(l+r)>>1;
	cdq(l,mid),cdq(mid+1,r);
	int I=l,J=mid+1,K=l;
	while(I<=mid&&J<=r)
	{
		if(q[p[I]].x<=q[p[J]].x)
		{
			if(!(~q[p[I]].z))
				bit.Del(q[p[I]].y);
			if(!q[p[I]].z)
				bit.Add(q[p[I]].y);
			tmp[K++]=p[I++];
		}
		else
		{
			if(q[p[J]].z>0)
				ans[q[p[J]].z]+=bit.Sum(q[p[J]].y);
			tmp[K++]=p[J++];
		}
	}
	while(I<=mid)
	{
		if(!(~q[p[I]].z))
			bit.Del(q[p[I]].y);
		if(!q[p[I]].z)
			bit.Add(q[p[I]].y);
		tmp[K++]=p[I++];
	}
	while(J<=r)
	{
		if(q[p[J]].z>0)
			ans[q[p[J]].z]+=bit.Sum(q[p[J]].y);
		tmp[K++]=p[J++];
	}
	rep(i,l,mid)
	{
		if(!(~q[p[i]].z))
			bit.Add(q[p[i]].y);
		if(!q[p[i]].z)
			bit.Del(q[p[i]].y);
	}
	rep(i,l,r)
		p[i]=tmp[i];
}

int m,op,l,r,x;
bitset<N> flag;
map<int,int> mp; int ccnt;
il void Solve()
{
	cin>>n>>m,bit.Clear(n);
	rep(i,1,n+1)
	{
		(i<=n)? (cin>>x,x=((!mp.count(x))? (mp[x]=++ccnt):mp[x])):x=0;
		odt.insert((node){i,i,x}),st[x].insert((node){i,i,x});
		iter it=st[x].lower_bound((node){i,i,x});
		(it==st[x].begin())? pre[i]=0:pre[i]=prev(it)->r;
		q[++qcnt]=(que){pre[i],i,0};
	}
	rep(i,1,m)
	{
		cin>>op;
		if(op==1)
			cin>>l>>r>>x,x=((!mp.count(x))? (mp[x]=++ccnt):mp[x]),Modify(l,r,x);
		if(op==2)
			cin>>l>>r,q[++qcnt]=(que){l-1,r,i},ans[i]=1-l,flag[i]=1;
	}
	rep(i,1,qcnt)
		p[i]=i;
	cdq(1,qcnt);
	for(int i=flag._Find_first(); i<=m; i=flag._Find_next(i))
		cout<<ans[i]<<'\n';
}
int main()
{
#ifdef LOCAL
	string fpre="test",isuf="in",osuf="out";
	assert(freopen((fpre+"."+isuf).c_str(),"r",stdin));
	assert(freopen((fpre+"."+osuf).c_str(),"w",stdout));
#endif
	int T=1;
	while(T--)
		Solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 5.88235
Accepted
time: 219ms
memory: 41360kb

input:

100000 100000
577442837 375864925 121344397 701359771 801344935 593698249 7589141 434023180 147695214 19052941 633869659 233328397 464997835 338373309 195367210 405248671 718602676 187433586 546688577 194670961 225021241 160996619 494381873 652597576 62343648 555457915 339196729 52469715 409071301 1...

output:

20689
32129
26778
13109
72041
21886
54721
36411
51052
11545
37233
25211
30330
70910
36893
69368
75702
51613
8189
16462
8923
9475
42801
41731
59048
27626
61660
36498
3390
41164
6603
50978
5940
59414
1965
4853
21567
76962
47467
33840
89978
75680
29636
26263
41339
29353
18357
4565
48901
44458
23423
327...

result:

ok 89876 lines

Test #2:

score: 5.88235
Accepted
time: 318ms
memory: 39672kb

input:

100000 100000
551 781 757 985 927 953 659 900 189 876 221 761 786 94 881 201 537 775 919 334 667 251 877 9 953 614 226 614 1 136 251 625 395 717 401 151 171 33 384 695 573 391 126 611 1 665 921 926 353 321 697 961 371 81 326 501 519 317 631 562 362 938 569 448 47 996 411 984 501 361 855 954 426 66 5...

output:

1000
992
738
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
999
957
893
1000
731
965
1000
993
1000
977
1000
1000
1000
1000
1000
1000
511
1000
1000
1000
1000
999
1000
1000
1000
541
1000
998
1000
1000
1000
1000
999
1000
314
1000
1000
984
1000
932
986
1000
1000
1000
1000
1000
1000
1000
1000
1000
974...

result:

ok 89962 lines

Test #3:

score: 5.88235
Accepted
time: 225ms
memory: 37948kb

input:

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

output:

10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
...

result:

ok 90008 lines

Test #4:

score: 5.88235
Accepted
time: 293ms
memory: 40004kb

input:

100000 100000
68 729 213 65 379 141 333 249 971 602 961 353 809 387 103 113 901 333 549 856 565 707 441 554 275 514 419 48 514 788 882 619 735 93 823 378 182 937 503 912 753 858 316 709 685 125 489 900 751 127 801 171 826 198 280 35 923 122 25 601 793 103 762 153 511 760 921 749 801 836 938 977 163 ...

output:

1000
1000
1000
986
841
1000
1000
1000
998
999
1000
517
1000
1000
939
994
1000
1000
1000
1000
1000
1000
997
1000
990
1000
1000
1000
1000
1000
1000
1000
1000
997
1000
153
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
993
1000
1000
1000
1000
757
937
1000
1000
1000
977
...

result:

ok 89982 lines

Test #5:

score: 5.88235
Accepted
time: 258ms
memory: 38804kb

input:

100000 100000
3705 8575 3001 4421 1623 3188 776 1946 4013 5189 151 6201 8377 5801 7341 3904 4745 5653 5415 1753 6361 929 5261 4254 548 1903 1763 9541 6537 8825 7147 1317 7179 5793 5769 3877 5333 4277 5125 5049 8157 8071 6811 5338 1189 1481 5819 9993 7447 5131 8111 676 9577 3749 1065 2521 6409 8635 5...

output:

7165
7562
4352
6561
7923
8848
9544
6252
6382
7628
6919
7690
7031
6146
9300
3504
9050
9470
3063
9667
9666
5218
3284
9543
9235
4932
9718
4645
2103
1998
9188
9209
3230
7432
8392
9712
293
8267
6745
8421
9693
9864
6190
616
4971
7703
9443
2766
9087
6636
8459
9696
6461
9566
7309
6797
5659
6424
7688
9885
82...

result:

ok 90029 lines

Test #6:

score: 5.88235
Accepted
time: 207ms
memory: 43732kb

input:

100000 100000
76287259 14179777 89914269 485972173 52445836 258302611 444952924 170780 687434419 386708309 20481133 5952421 660562768 322940661 111197779 212697607 1129761 725797501 25480981 458605317 501570715 27372681 552417273 900472397 146351284 697326651 497333233 312438691 190065574 410936899 ...

output:

29029
35388
3292
13208
1448
3629
2571
36113
1087
52440
36454
1
71550
39618
6370
21513
40920
17451
71818
65743
36673
4445
8736
76752
25388
102
50121
36721
49024
19297
17782
12788
20772
51705
4897
41876
41407
40773
23608
2239
23950
15411
24059
54518
8888
7165
12444
1365
39283
15336
10465
72421
60401
3...

result:

ok 89943 lines

Test #7:

score: 5.88235
Accepted
time: 215ms
memory: 42736kb

input:

100000 100000
899173541 144418561 110346531 533170093 312873856 199775137 54855733 210600766 150989313 18051513 126341361 104962075 484106257 89969497 110508310 185405703 254393281 734151947 211945001 18210826 263919547 22526265 99814534 25848987 115847613 507920881 541185282 156509508 17534830 2601...

output:

24154
1751
16172
35046
19138
15711
21776
43452
17663
23888
18430
52472
42303
2439
46298
14834
36928
46225
20954
24920
10361
46070
12996
51210
11445
24609
26631
15879
18540
2427
31367
10169
640
30921
71387
35899
60634
28683
37317
16381
37719
37888
5055
43205
60738
9856
10011
22412
17404
39735
3830
38...

result:

ok 90261 lines

Test #8:

score: 5.88235
Accepted
time: 251ms
memory: 46980kb

input:

100000 100000
524574897 865754121 547062450 17547982 297537057 584043373 160454401 112807234 46475901 489556669 845229841 350409295 388256545 296243425 165066320 12430176 380568637 347479267 120985264 276213505 40487579 389589725 233377905 268843225 820657 34457501 82434067 112375180 919335961 74290...

output:

18723
46558
9017
10548
27380
25808
1
1
1135
1
4311
1
26350
1
9827
19325
1
1
3
504
3
3
1
2
2
2
2
6429
4001
1
2
11973
3
1
2
1
3
1
1
1
1
3
1
1
1
2
2
2
3
1614
2369
1065
4730
3
3
1
3
776
1
2491
5
1
2
3
1411
1
4
4
5
5
5
4466
1
5
2
3
1
1
4347
1
2
6
1065
1
1339
2875
1
1711
2
2
1
2
3
1
1
3
3
1
1084
3
1
2
1
2...

result:

ok 89966 lines

Test #9:

score: 5.88235
Accepted
time: 411ms
memory: 43880kb

input:

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

output:

10
10
10
10
1
1
2
1
3
1
10
10
3
2
1
10
3
10
3
5
5
4
10
3
1
1
4
10
1
3
5
3
2
1
2
10
1
10
2
2
2
2
2
2
1
1
2
2
3
1
4
1
3
1
5
1
1
1
6
2
6
3
3
3
1
3
4
1
2
5
1
3
3
4
2
5
4
2
4
1
6
6
3
2
1
6
2
1
1
6
1
2
3
5
3
2
3
1
3
2
2
1
3
3
2
3
3
4
3
1
3
1
3
1
1
2
1
1
2
2
3
1
2
2
1
1
3
1
3
3
1
4
2
2
2
4
3
2
1
4
3
2
1
3
...

result:

ok 69956 lines

Test #10:

score: 5.88235
Accepted
time: 527ms
memory: 46344kb

input:

100000 100000
727 414 41 248 13 869 501 821 195 331 541 551 590 809 181 236 21 681 429 192 538 105 751 581 697 981 881 955 533 95 939 265 125 211 719 161 995 361 564 509 270 401 266 137 551 473 112 431 763 796 593 409 713 381 523 1000 986 501 769 206 898 291 866 181 36 251 794 241 961 553 601 977 59...

output:

1000
239
999
426
978
1000
1000
1000
1000
1000
1000
788
977
820
1000
1000
1000
1000
998
1000
744
1000
998
1000
1000
1000
1000
1000
1000
1000
1000
956
999
1000
697
1000
1000
995
987
1000
913
1000
1000
1000
1000
1000
999
1000
1000
1000
1000
1000
998
999
678
1000
958
1000
1000
1000
1000
1000
1000
739
10...

result:

ok 60205 lines

Test #11:

score: 5.88235
Accepted
time: 456ms
memory: 44824kb

input:

100000 100000
8311 73953 91312 36913 41841 46601 68577 35357 29783 60875 87462 20749 4609 48485 69769 62457 93009 18677 10541 66091 79676 66569 34737 57236 70305 93425 28019 59017 29465 97017 65473 58751 14393 10645 98301 37009 99783 75899 61390 86831 91825 48945 54239 46195 9312 7975 46451 87038 97...

output:

14441
30066
15717
1
27386
24395
22432
19301
779
43568
3
23710
18557
16129
27057
12946
24454
4906
37212
9972
2655
38052
40311
1160
7659
3307
16884
31686
38776
11009
18375
26901
11468
1
1
21237
16480
10079
37796
37042
31479
2384
8148
2
2
17216
13419
4114
29571
19200
24333
20377
8877
16170
8371
2805
29...

result:

ok 69785 lines

Test #12:

score: 5.88235
Accepted
time: 336ms
memory: 45452kb

input:

100000 100000
24844576 148725322 251743974 368356219 1734440 416212681 779241491 469728540 267187583 443877049 679476241 328827424 394212799 875812521 235646698 24161727 278485501 79723381 10268071 449939209 246323525 142621561 28398196 172700161 852658048 119644658 20815138 564720771 82325229 46577...

output:

38448
34473
40591
21657
13072
26972
53401
27413
5226
36331
30028
5746
16758
49697
22248
5012
39957
16542
5428
22686
72950
14719
5342
72604
13590
11345
5460
13254
3050
42032
37944
3558
1
16616
14074
36882
19188
39933
4561
3
37656
17528
18406
11654
23061
50195
45106
13979
51981
34341
4
16444
3
3008
10...

result:

ok 70075 lines

Test #13:

score: 5.88235
Accepted
time: 490ms
memory: 41728kb

input:

100000 100000
481 9 351 913 847 547 415 666 911 166 497 883 9 293 49 725 944 151 673 476 451 55 87 303 556 313 404 539 496 721 666 1 962 497 707 756 180 57 16 41 209 637 251 311 283 757 646 717 923 523 617 376 601 17 513 225 93 307 249 857 339 838 109 114 300 75 313 710 557 577 189 433 983 861 423 9...

output:

1000
998
1000
999
1000
1000
1000
1000
1000
999
1000
2
2
969
1000
3
947
1000
793
1000
1000
931
4
983
1000
1000
1000
1000
1000
247
1000
1000
1000
1000
1000
1000
1000
907
1000
3
1000
3
999
943
1000
999
1000
997
1000
1000
1
1000
1000
992
1000
999
1000
1000
1000
1000
987
1000
2
997
1000
1000
999
1000
977...

result:

ok 70077 lines

Test #14:

score: 5.88235
Accepted
time: 463ms
memory: 44376kb

input:

100000 100000
43 45 5 100 1 30 20 66 68 93 31 53 65 13 63 51 51 45 13 49 11 69 26 55 56 65 49 1 31 77 7 66 61 95 41 80 71 53 31 27 29 13 30 20 85 58 25 73 19 85 14 37 21 4 17 56 87 91 21 2 73 16 85 91 73 93 82 66 73 86 19 91 61 47 71 69 56 91 15 49 35 1 86 10 74 41 97 10 88 93 91 9 93 66 47 93 63 9 ...

output:

100
100
100
100
100
100
100
100
100
2
100
100
100
2
100
100
100
100
100
2
100
100
100
100
100
100
100
100
100
1
100
4
100
100
100
1
100
1
100
100
73
100
100
100
100
100
100
100
3
100
100
100
100
100
100
100
100
1
100
100
100
100
100
1
100
100
100
100
100
3
100
100
100
100
100
3
100
100
1
100
100
100...

result:

ok 69911 lines

Test #15:

score: 5.88235
Accepted
time: 464ms
memory: 41764kb

input:

100000 100000
42 75 157 129 3 222 171 102 165 5 61 125 27 124 78 217 143 96 176 110 195 17 129 127 179 223 11 222 63 48 173 135 15 199 227 151 67 135 57 120 214 138 215 213 28 80 131 108 153 152 193 38 22 71 200 64 107 153 37 115 94 140 93 85 188 77 229 167 161 70 99 161 28 80 14 74 66 91 35 209 55 ...

output:

233
233
233
233
233
233
233
233
2
232
233
233
233
233
233
233
4
233
233
233
233
233
233
233
232
233
233
233
233
233
233
233
1
233
3
233
233
233
3
233
233
233
233
233
5
233
233
233
1
1
6
233
233
233
233
233
3
233
233
5
233
233
233
233
233
233
233
233
233
1
233
233
233
233
233
233
233
233
233
233
233
...

result:

ok 70068 lines

Test #16:

score: 5.88235
Accepted
time: 458ms
memory: 43652kb

input:

100000 100000
144 24 67 42 12 86 135 52 74 53 91 12 123 15 220 72 166 95 148 15 147 227 95 231 165 30 63 217 229 143 48 93 187 79 11 57 148 72 14 32 55 47 54 41 149 5 176 28 167 49 15 219 121 44 65 10 124 89 227 50 109 211 143 142 190 93 199 148 109 202 127 192 19 2 227 114 221 145 195 1 153 148 205...

output:

233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
233
...

result:

ok 70076 lines

Test #17:

score: 5.88235
Accepted
time: 506ms
memory: 45768kb

input:

100000 100000
16257 9627 20724 21178 20093 18201 11341 21876 17086 3716 13793 4728 10008 12645 5283 21903 20512 3534 959 15949 14823 5933 18186 5189 10843 9376 7498 15040 14215 16836 19705 12216 12159 8115 21064 7826 8164 11386 5617 11998 19990 1920 6065 3965 20133 13395 16868 20680 9649 4204 17723 ...

output:

21460
19201
19745
19903
19834
19237
20584
19359
19965
19399
20566
20471
20382
20467
19453
20294
20241
19679
20346
20210
20399
19667
19636
20536
19397
19401
20487
20601
20195
20021
20254
19638
20299
20386
20268
19979
19414
20599
19409
19584
20098
19289
19688
19528
20350
20424
19781
20550
19320
19661
...

result:

ok 69863 lines