QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#886091 | #10053. Post Office | Lyz09 | 100 ✓ | 1282ms | 469996kb | C++14 | 6.0kb | 2025-02-06 20:30:28 | 2025-02-06 20:30:29 |
Judging History
answer
#include<iostream>
#include<vector>
#include<set>
using namespace std;
#define N 200010
int n,to[N],m,a[N],b[N],qq[N],ans,rr[N];
int qwq,cid[N],td[N],cnt,dep[N],dfn[N],ed[N],ys[N];
bool vis[N],ins[N],inc[N];
vector<int> g[N],pi[N],pe[N],qi[N],qe[N];
set<int> s;
multiset<int> s2;
struct node
{
int len,sum,ma;
friend node operator+(node a,node b)
{
return (node){a.len+b.len,a.sum+b.sum,max(a.ma-b.len+b.sum,b.ma)};
}
};
class sgtree
{
public:
#define sN 30000010
int cnt,rt[N],ls[sN],rs[sN],qwq=600000;
node a[sN];
void pushdown(int o,int l,int r)
{
if(l==r||ls[o]||rs[o])
return;
int mid=l+r>>1;
ls[o]=++cnt;
a[ls[o]]=(node){mid-l+1,0,0};
rs[o]=++cnt;
a[rs[o]]=(node){r-mid,0,0};
}
void upd(int o,int l,int r)
{
int mid=l+r>>1;
node w1=(node){mid-l+1,0,0};
node w2=(node){r-mid,0,0};
if(ls[o])
w1=a[ls[o]];
if(rs[o])
w2=a[rs[o]];
a[o]=w1+w2;
}
int update(int o,int l,int r,int x,int k)
{
if(l>x||r<x||!o)
return o;
int d=++cnt;
a[d]=a[o];
if(l==r)
{
a[d].sum+=k;
a[d].ma=max(a[d].sum,0);
return d;
}
pushdown(o,l,r);
int mid=l+r>>1;
ls[d]=update(ls[o],l,mid,x,k);
rs[d]=update(rs[o],mid+1,r,x,k);
upd(d,l,r);
return d;
}
int add(int o,int x,int k)
{
int tmp=update(o,1,qwq,x,k);
return tmp;
}
int merge(int o1,int o2,int l,int r)
{
if(!o1||!o2)
return o1+o2;
if(l==r)
{
a[o1].sum+=a[o2].sum;
a[o1].ma=max(a[o1].sum,0);
return o1;
}
int mid=l+r>>1;
ls[o1]=merge(ls[o1],ls[o2],l,mid);
rs[o1]=merge(rs[o1],rs[o2],mid+1,r);
upd(o1,l,r);
return o1;
}
int Merge(int x,int y)
{
return merge(x,y,1,qwq);
}
node query(int o,int l,int r,int x,int y)
{
if(l>y||r<x)
return (node){0,0,0};
if(!o)
return (node){min(y,r)-max(l,x)+1,0,0};
if(l>=x&&r<=y)
return a[o];
int mid=l+r>>1;
node q1=query(ls[o],l,mid,x,y);
node q2=query(rs[o],mid+1,r,x,y);
return q1+q2;
}
int ask(int rt)
{
// cerr<<"UUU:"<<a[rt].sum<<endl;
int l=0,r=qwq,ans=qwq;
while(l<=r)
{
int mid=l+r>>1;
node res=query(rt,1,qwq,1,mid);
// cerr<<"umnik"<<mid<<"::"<<res.len<<" "<<res.sum<<" "<<res.ma<<endl;
if(res.sum==a[rt].sum&&res.ma<=0)
{
ans=mid;
r=mid-1;
}
else
{
l=mid+1;
}
}
return ans;
}
int init()
{
int u=++cnt;
ls[u]=0;
rs[u]=0;
a[u]=(node){qwq,0,0};
return u;
}
}tr;
void dfs0(int u)
{
vis[u]=1;
ins[u]=1;
if(ins[to[u]])
inc[to[u]]=1;
if(vis[to[u]])
{
ins[u]=0;
return;
}
dfs0(to[u]);
ins[u]=0;
}
void dfs1(int u)
{
dfn[u]=++cnt;
for(int v:g[u])
{
cid[v]=cid[u];
dep[v]=dep[u]+1;
td[v]=td[u];
dfs1(v);
}
ed[u]=cnt;
}
void init()
{
for(int i=1;i<=n;i++)
if(!vis[i])
dfs0(i);
for(int i=1;i<=n;i++)
if(inc[i]&&(!inc[to[i]]||to[i]==i))
{
cid[i]=++qwq;
int now=to[i];
while(!inc[now])
{
inc[now]=1;
cid[now]=cid[i];
now=to[now];
}
}
for(int i=1;i<=n;i++)
if(!inc[i])
g[to[i]].push_back(i);
for(int i=1;i<=n;i++)
if(inc[i])
{
td[i]=i;
dfs1(i);
}
}
bool check(int x,int y)
{
if(cid[x]!=cid[y])
return 0;
if(!inc[y]&&!(dfn[x]>=dfn[y]&&dfn[x]<=ed[y]))
return 0;
return 1;
}
void dfs2(int u)
{
if(!g[u].size())
tr.rt[u]=tr.init();
for(int v:g[u])
{
dfs2(v);
tr.rt[u]=tr.Merge(tr.rt[u],tr.rt[v]);
}
for(int x:pi[u])
tr.rt[u]=tr.add(tr.rt[u],dep[a[x]],1);
for(int x:pe[u])
tr.rt[u]=tr.add(tr.rt[u],dep[a[x]],-1);
int w=tr.ask(tr.rt[u]);
ans=max(ans,w-dep[u]);
}
void solvec(int bbb)
{
if(to[bbb]==bbb)
return;
vector<int> d;
while(!vis[bbb])
{
vis[bbb]=1;
d.push_back(bbb);
bbb=to[bbb];
}
s.clear();
// tr.cnt=0;
tr.rt[0]=tr.init();
for(int i=0;i<d.size();i++)
ys[d[i]]=d.size()-i;
for(int u:d)
{
for(int x:qi[u])
{
// cerr<<"insA:"<<x<<"|"<<a[x]<<" "<<b[x]<<"||"<<ys[td[a[x]]]<<"+"<<qq[x]<<"+"<<d.size()<<endl;
s.insert(x);
rr[x]=1;
tr.rt[0]=tr.add(tr.rt[0],ys[td[a[x]]]+qq[x]+d.size(),1);
}
for(int x:qe[u])
{
if(s.find(x)!=s.end())
{
s.erase(x);
// cerr<<"ersA:"<<x<<endl;
tr.rt[0]=tr.add(tr.rt[0],ys[td[a[x]]]+qq[x]+d.size(),-1);
}
}
}
for(int u:d)
{
for(int x:qi[u])
{
// cerr<<"insB:"<<x<<"|"<<a[x]<<" "<<b[x]<<"||"<<ys[td[a[x]]]<<"+"<<qq[x]<<endl;
s.insert(x);
rr[x]=0;
tr.rt[0]=tr.add(tr.rt[0],ys[td[a[x]]]+qq[x],1);
}
for(int x:qe[u])
{
if(s.find(x)!=s.end())
{
s.erase(x);
// cerr<<"ersB:"<<x<<"||"<<rr[x]<<endl;
if(rr[x])
tr.rt[0]=tr.add(tr.rt[0],ys[td[a[x]]]+qq[x]+d.size(),-1);
else
tr.rt[0]=tr.add(tr.rt[0],ys[td[a[x]]]+qq[x],-1);
}
}
// cerr<<"set:-----"<<endl;
// for(int ww:s)
// cerr<<ww<<" ";
// cerr<<endl;
// if(u==d.back())
// continue;
// cerr<<"#2 "<<u<<":"<<tr.ask(tr.rt[0])<<" - "<<ys[u]<<endl;
ans=max(ans,tr.ask(tr.rt[0])-ys[u]);
}
return;
s2.clear();
for(int x:s)
s2.insert(ys[td[a[x]]]-1+qq[x]);
int las=0,sum=0;
for(int x:s2)
{
// cerr<<"!!!"<<x<<endl;
sum=max(0,sum-(x-las)+1);
las=x;
}
// cerr<<"#3 >>"<<d.back()<<":"<<las<<"+"<<sum<<endl;
ans=max(ans,las+sum);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
cin>>to[i];
init();
cin>>m;
for(int i=1;i<=m;i++)
{
cin>>a[i]>>b[i];
if(!check(a[i],b[i]))
{
cout<<"-1"<<endl;
return 0;
}
if(!inc[a[i]])
pi[a[i]].push_back(i);
if(!inc[b[i]])
pe[b[i]].push_back(i);
else if(!inc[a[i]])
pe[td[a[i]]].push_back(i);
if(inc[b[i]])
{
// cerr<<i<<"-->"<<td[a[i]]<<endl;
qq[i]=dep[a[i]];
qi[td[a[i]]].push_back(i);
qe[b[i]].push_back(i);
}
}
for(int i=1;i<=n;i++)
if(inc[i])
dfs2(i);
for(int i=1;i<=n;i++)
vis[i]=0;
for(int i=1;i<=n;i++)
if(inc[i]&&!vis[i])
{
solvec(i);
}
cout<<ans<<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 3
Accepted
Test #1:
score: 3
Accepted
time: 4ms
memory: 38792kb
input:
3000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...
output:
1119
result:
ok single line: '1119'
Test #2:
score: 3
Accepted
time: 4ms
memory: 38752kb
input:
3000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...
output:
774
result:
ok single line: '774'
Test #3:
score: 3
Accepted
time: 3ms
memory: 36660kb
input:
3000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...
output:
-1
result:
ok single line: '-1'
Test #4:
score: 3
Accepted
time: 2ms
memory: 36708kb
input:
3000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...
output:
-1
result:
ok single line: '-1'
Test #5:
score: 3
Accepted
time: 2ms
memory: 36676kb
input:
3000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...
output:
-1
result:
ok single line: '-1'
Test #6:
score: 3
Accepted
time: 3ms
memory: 36688kb
input:
3000 1 1 1 2 4 4 5 7 7 5 4 11 6 7 6 12 5 6 9 14 16 11 18 1 18 11 16 8 6 28 10 6 30 33 30 1 11 21 36 21 31 35 14 40 26 35 26 24 21 20 3 15 43 36 20 37 33 14 14 46 12 1 38 1 29 57 10 24 4 34 67 29 37 37 73 47 34 32 29 65 48 21 39 24 75 51 75 85 11 27 69 83 32 41 67 32 62 42 10 73 87 2 88 29 81 71 41 2...
output:
-1
result:
ok single line: '-1'
Test #7:
score: 3
Accepted
time: 1ms
memory: 36584kb
input:
3000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
-1
result:
ok single line: '-1'
Subtask #2:
score: 9
Accepted
Test #8:
score: 9
Accepted
time: 2ms
memory: 40688kb
input:
5 2 1 1 3 1 5 1 2 4 1 5 1 3 1 4 1
output:
3
result:
ok single line: '3'
Test #9:
score: 9
Accepted
time: 1ms
memory: 36604kb
input:
5 2 1 2 3 3 5 3 2 5 2 5 1 4 2 2 1
output:
4
result:
ok single line: '4'
Test #10:
score: 9
Accepted
time: 2ms
memory: 38656kb
input:
5 2 1 1 2 4 5 5 1 4 1 3 2 5 2 4 2
output:
4
result:
ok single line: '4'
Test #11:
score: 9
Accepted
time: 3ms
memory: 40688kb
input:
5 2 1 1 1 1 5 1 2 3 1 2 1 4 2 2 1
output:
2
result:
ok single line: '2'
Test #12:
score: 9
Accepted
time: 2ms
memory: 38652kb
input:
5 2 1 1 2 4 5 3 1 5 2 1 2 3 1 4 2
output:
2
result:
ok single line: '2'
Test #13:
score: 9
Accepted
time: 3ms
memory: 40684kb
input:
5 2 1 1 1 2 5 5 2 3 2 3 1 5 2 2 1
output:
2
result:
ok single line: '2'
Test #14:
score: 9
Accepted
time: 1ms
memory: 40692kb
input:
5 2 1 2 2 4 5 2 1 5 2 3 2 5 1 2 1
output:
3
result:
ok single line: '3'
Test #15:
score: 9
Accepted
time: 0ms
memory: 40692kb
input:
5 2 1 2 3 4 5 4 1 5 2 5 2 3 1 1 2
output:
4
result:
ok single line: '4'
Test #16:
score: 9
Accepted
time: 3ms
memory: 38648kb
input:
10 2 3 4 5 1 1 1 4 6 2 10 4 2 1 4 6 2 3 1 4 3 10 4 7 3 5 3 6 2 7 1
output:
7
result:
ok single line: '7'
Test #17:
score: 9
Accepted
time: 1ms
memory: 38648kb
input:
10 2 3 4 5 1 2 6 5 8 1 10 3 4 10 2 4 1 6 2 10 4 4 1 7 1 5 1 10 3 1 3
output:
6
result:
ok single line: '6'
Test #18:
score: 9
Accepted
time: 2ms
memory: 38444kb
input:
10 2 3 4 5 1 5 3 5 5 8 10 5 3 10 3 8 5 9 4 2 4 4 3 3 4 1 4 10 4 6 1
output:
7
result:
ok single line: '7'
Test #19:
score: 9
Accepted
time: 2ms
memory: 38652kb
input:
10 2 3 4 5 1 2 5 6 4 7 10 7 5 10 1 3 2 1 5 3 1 10 3 4 1 3 5 1 5 7 4
output:
7
result:
ok single line: '7'
Test #20:
score: 9
Accepted
time: 1ms
memory: 38524kb
input:
10 2 3 4 5 1 4 3 5 2 5 10 7 4 5 2 10 5 6 5 6 5 8 5 8 3 3 4 4 2 9 5
output:
4
result:
ok single line: '4'
Test #21:
score: 9
Accepted
time: 10ms
memory: 45824kb
input:
3000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...
output:
1563
result:
ok single line: '1563'
Test #22:
score: 9
Accepted
time: 15ms
memory: 44756kb
input:
3000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...
output:
1547
result:
ok single line: '1547'
Test #23:
score: 9
Accepted
time: 10ms
memory: 45560kb
input:
3000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...
output:
1574
result:
ok single line: '1574'
Test #24:
score: 9
Accepted
time: 2ms
memory: 36416kb
input:
5 2 1 1 1 1 5 1 2 3 1 2 1 5 4 2 1
output:
-1
result:
ok single line: '-1'
Test #25:
score: 9
Accepted
time: 4ms
memory: 34540kb
input:
10 2 3 4 5 1 7 8 9 10 6 10 3 5 3 5 1 5 3 4 5 3 10 6 4 6 6 7 9 10 2 1
output:
-1
result:
ok single line: '-1'
Test #26:
score: 9
Accepted
time: 2ms
memory: 36688kb
input:
3000 1 1 1 3 3 4 4 7 7 8 5 7 1 4 3 15 15 11 2 18 9 7 2 23 3 17 14 10 18 1 28 20 25 33 28 11 21 6 2 3 36 2 41 6 28 26 7 12 26 48 6 37 28 42 21 27 47 21 46 23 54 34 29 2 49 63 31 47 39 39 47 37 69 59 9 65 62 37 64 24 47 13 6 19 31 84 59 40 5 9 45 34 11 43 5 78 93 70 38 2 94 5 97 53 43 94 47 32 69 17 3...
output:
-1
result:
ok single line: '-1'
Test #27:
score: 9
Accepted
time: 7ms
memory: 43436kb
input:
3000 89 1 1 3 2 5 6 3 6 6 7 11 8 12 14 12 14 13 16 15 16 21 18 23 22 23 24 27 24 26 29 27 32 30 31 34 32 33 35 38 36 39 41 42 41 42 42 43 45 49 46 51 48 50 51 52 55 56 57 57 58 61 59 63 61 62 63 67 68 68 66 67 69 73 72 74 73 74 74 76 77 79 79 79 82 82 85 85 84 88 90 91 92 89 91 93 96 97 94 98 99 100...
output:
7
result:
ok single line: '7'
Test #28:
score: 9
Accepted
time: 10ms
memory: 40924kb
input:
3000 1699 1 1 3 2 4 5 3 2 4 9 7 5 13 10 12 12 10 11 16 18 19 21 18 18 23 22 26 22 26 23 31 27 29 28 28 29 33 31 35 34 34 36 38 39 39 45 41 43 46 49 50 48 53 54 53 54 54 54 57 55 61 56 63 57 65 60 64 62 68 69 70 65 73 69 73 76 73 73 73 79 75 75 77 81 85 86 87 87 89 88 85 92 86 93 92 90 92 95 94 96 98...
output:
7
result:
ok single line: '7'
Test #29:
score: 9
Accepted
time: 5ms
memory: 45816kb
input:
3000 89 1 1 3 2 5 6 3 6 6 7 11 8 12 14 12 14 13 16 15 16 21 18 23 22 23 24 27 24 26 29 27 32 30 31 34 32 33 35 38 36 39 41 42 41 42 42 43 45 49 46 51 48 50 51 52 55 56 57 57 58 61 59 63 61 62 63 67 68 68 66 67 69 73 72 74 73 74 74 76 77 79 79 79 82 82 85 85 84 88 90 91 92 89 91 93 96 97 94 98 99 100...
output:
3975
result:
ok single line: '3975'
Test #30:
score: 9
Accepted
time: 6ms
memory: 45216kb
input:
3000 1699 1 1 3 2 4 5 3 2 4 9 7 5 13 10 12 12 10 11 16 18 19 21 18 18 23 22 26 22 26 23 31 27 29 28 28 29 33 31 35 34 34 36 38 39 39 45 41 43 46 49 50 48 53 54 53 54 54 54 57 55 61 56 63 57 65 60 64 62 68 69 70 65 73 69 73 76 73 73 73 79 75 75 77 81 85 86 87 87 89 88 85 92 86 93 92 90 92 95 94 96 98...
output:
3631
result:
ok single line: '3631'
Test #31:
score: 9
Accepted
time: 11ms
memory: 45428kb
input:
3000 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 92 91 94 93 96 95 98 97 100 99 102...
output:
9
result:
ok single line: '9'
Test #32:
score: 9
Accepted
time: 8ms
memory: 43132kb
input:
3000 89 1 1 3 2 5 6 3 6 6 7 11 8 12 14 12 14 13 16 15 16 21 18 23 22 23 24 27 24 26 29 27 32 30 31 34 32 33 35 38 36 39 41 42 41 42 42 43 45 49 46 51 48 50 51 52 55 56 57 57 58 61 59 63 61 62 63 67 68 68 66 67 69 73 72 74 73 74 74 76 77 79 79 79 82 82 85 85 84 88 90 91 92 89 91 93 96 97 94 98 99 100...
output:
13
result:
ok single line: '13'
Test #33:
score: 9
Accepted
time: 7ms
memory: 45660kb
input:
3000 1699 1 1 3 2 4 5 3 2 4 9 7 5 13 10 12 12 10 11 16 18 19 21 18 18 23 22 26 22 26 23 31 27 29 28 28 29 33 31 35 34 34 36 38 39 39 45 41 43 46 49 50 48 53 54 53 54 54 54 57 55 61 56 63 57 65 60 64 62 68 69 70 65 73 69 73 76 73 73 73 79 75 75 77 81 85 86 87 87 89 88 85 92 86 93 92 90 92 95 94 96 98...
output:
13
result:
ok single line: '13'
Subtask #3:
score: 13
Accepted
Test #34:
score: 13
Accepted
time: 94ms
memory: 207980kb
input:
2 1 1 200000 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1...
output:
200000
result:
ok single line: '200000'
Test #35:
score: 13
Accepted
time: 424ms
memory: 258880kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
200000
result:
ok single line: '200000'
Test #36:
score: 13
Accepted
time: 285ms
memory: 256508kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
200008
result:
ok single line: '200008'
Test #37:
score: 13
Accepted
time: 8ms
memory: 43608kb
input:
3000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
5998
result:
ok single line: '5998'
Test #38:
score: 13
Accepted
time: 135ms
memory: 260200kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
399998
result:
ok single line: '399998'
Test #39:
score: 13
Accepted
time: 7ms
memory: 43492kb
input:
3000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
3000
result:
ok single line: '3000'
Test #40:
score: 13
Accepted
time: 418ms
memory: 254972kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
200000
result:
ok single line: '200000'
Subtask #4:
score: 25
Accepted
Test #41:
score: 25
Accepted
time: 531ms
memory: 262432kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
199401
result:
ok single line: '199401'
Test #42:
score: 25
Accepted
time: 516ms
memory: 262996kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
199604
result:
ok single line: '199604'
Test #43:
score: 25
Accepted
time: 2ms
memory: 36808kb
input:
3000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
-1
result:
ok single line: '-1'
Test #44:
score: 25
Accepted
time: 51ms
memory: 63888kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
-1
result:
ok single line: '-1'
Test #45:
score: 25
Accepted
time: 10ms
memory: 40036kb
input:
3000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
1496
result:
ok single line: '1496'
Test #46:
score: 25
Accepted
time: 497ms
memory: 261256kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
99857
result:
ok single line: '99857'
Test #47:
score: 25
Accepted
time: 8ms
memory: 43604kb
input:
3000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
5964
result:
ok single line: '5964'
Test #48:
score: 25
Accepted
time: 162ms
memory: 260216kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
398029
result:
ok single line: '398029'
Test #49:
score: 25
Accepted
time: 8ms
memory: 41988kb
input:
3000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
2490
result:
ok single line: '2490'
Test #50:
score: 25
Accepted
time: 538ms
memory: 265812kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
195055
result:
ok single line: '195055'
Subtask #5:
score: 11
Accepted
Test #51:
score: 11
Accepted
time: 224ms
memory: 331360kb
input:
2 2 1 200000 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 2 1 2 2 1 2 1 1 2 2 1 2 1 1 2 1 2 2 1 1 2 1 2 2 1 2 1 1 2 1 2 1 2 2 1 2 1 2 1 2 1 1 2 2 1 2 1 2 1 1 2 2 1 1 2 1 2 1 2 1 2 2 1 2 1 2 1 2 1 1 2 2 1 1 2 1 2 1 2 2 1 1 2 1 2 1 2 1 2 2 1 2 1 2 1 1 2 1 2 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 1 1 2 1 2 2 1 2 1...
output:
100031
result:
ok single line: '100031'
Test #52:
score: 11
Accepted
time: 1125ms
memory: 355576kb
input:
200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
199999
result:
ok single line: '199999'
Test #53:
score: 11
Accepted
time: 1116ms
memory: 357548kb
input:
200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
199999
result:
ok single line: '199999'
Test #54:
score: 11
Accepted
time: 8ms
memory: 45680kb
input:
3000 3000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...
output:
1499
result:
ok single line: '1499'
Test #55:
score: 11
Accepted
time: 1079ms
memory: 387904kb
input:
200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
99898
result:
ok single line: '99898'
Test #56:
score: 11
Accepted
time: 10ms
memory: 45904kb
input:
3000 3000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...
output:
3098
result:
ok single line: '3098'
Test #57:
score: 11
Accepted
time: 898ms
memory: 323384kb
input:
200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
200586
result:
ok single line: '200586'
Test #58:
score: 11
Accepted
time: 8ms
memory: 45060kb
input:
3000 3000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...
output:
6
result:
ok single line: '6'
Test #59:
score: 11
Accepted
time: 594ms
memory: 393116kb
input:
200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
8
result:
ok single line: '8'
Subtask #6:
score: 25
Accepted
Test #60:
score: 25
Accepted
time: 447ms
memory: 269056kb
input:
200000 1 1 1 3 3 2 5 3 4 6 9 3 3 9 14 13 4 2 18 9 3 11 20 13 7 13 14 6 13 2 22 14 5 9 19 7 28 22 10 37 37 26 15 39 18 31 18 19 22 6 4 22 29 30 43 38 33 39 19 10 14 25 35 5 3 50 34 13 60 44 31 47 67 27 52 26 48 30 18 63 76 80 49 16 39 16 59 77 60 26 84 50 54 36 75 77 72 77 1 45 13 20 86 19 56 9 47 82...
output:
119708
result:
ok single line: '119708'
Test #61:
score: 25
Accepted
time: 459ms
memory: 268268kb
input:
200000 1 1 1 1 3 4 5 2 3 3 7 11 6 4 7 3 1 17 3 1 3 2 22 16 9 20 16 26 1 17 29 24 17 24 1 26 30 14 37 27 21 14 29 36 5 11 46 47 7 8 39 23 16 52 38 34 19 10 29 50 32 8 19 29 28 61 12 26 39 48 44 56 37 43 32 37 28 23 56 49 33 60 77 12 66 37 17 85 42 52 75 68 91 4 71 68 91 39 86 97 94 48 1 101 97 72 60 ...
output:
80568
result:
ok single line: '80568'
Test #62:
score: 25
Accepted
time: 3ms
memory: 36636kb
input:
3000 1 1 1 3 2 2 3 6 4 5 2 7 5 2 10 9 9 15 8 14 20 14 21 19 1 13 8 18 17 15 22 15 19 31 26 10 3 37 36 39 21 30 2 14 19 11 31 40 4 31 2 43 18 2 32 28 50 26 40 53 17 19 31 31 37 52 19 41 66 35 26 26 28 33 19 71 61 31 54 16 11 81 35 17 33 58 30 48 18 77 90 4 45 11 31 74 10 14 10 66 1 27 57 81 80 14 86 ...
output:
-1
result:
ok single line: '-1'
Test #63:
score: 25
Accepted
time: 41ms
memory: 43044kb
input:
200000 1 1 2 2 4 3 1 4 2 9 4 7 10 5 14 12 12 8 5 3 15 11 22 10 7 18 1 8 2 1 29 21 25 8 19 14 15 28 22 30 35 21 14 5 5 40 17 46 25 31 23 36 46 5 35 10 22 49 30 7 30 56 17 25 23 41 18 4 46 23 26 35 40 36 44 48 4 43 45 61 6 64 18 42 5 44 51 35 49 87 49 73 76 49 73 82 21 84 70 93 14 25 33 23 22 19 85 31...
output:
-1
result:
ok single line: '-1'
Test #64:
score: 25
Accepted
time: 6ms
memory: 41580kb
input:
3000 1 1 2 3 3 5 3 6 7 6 9 11 9 10 12 15 16 16 15 16 20 21 22 22 22 23 23 27 28 29 29 30 31 30 33 33 35 37 36 36 39 41 41 40 42 45 44 46 45 46 50 51 50 50 53 52 54 57 58 56 60 58 60 63 63 62 66 67 67 67 68 69 71 71 71 74 73 77 76 76 78 78 79 81 81 85 85 87 85 88 87 89 92 92 92 94 93 96 98 99 97 100 ...
output:
7
result:
ok single line: '7'
Test #65:
score: 25
Accepted
time: 7ms
memory: 43360kb
input:
3000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:
3000
result:
ok single line: '3000'
Test #66:
score: 25
Accepted
time: 403ms
memory: 260652kb
input:
200000 1 1 1 2 1 3 4 7 5 7 10 8 10 13 14 14 13 14 18 17 18 19 20 23 23 23 24 27 25 28 27 30 31 33 33 34 33 37 38 37 40 38 41 40 42 44 46 47 48 46 49 51 51 51 53 52 54 54 58 56 59 59 62 61 64 63 66 65 65 69 69 70 69 71 72 75 75 75 76 78 77 80 82 82 81 83 84 87 85 86 90 91 90 90 91 93 95 96 96 99 97 9...
output:
9
result:
ok single line: '9'
Test #67:
score: 25
Accepted
time: 408ms
memory: 252988kb
input:
200000 1 1 2 3 4 2 6 6 4 7 10 7 10 10 10 11 14 15 17 19 20 20 22 20 23 25 22 23 25 27 30 27 28 29 31 35 34 37 37 35 37 39 39 42 42 43 45 46 45 45 48 47 48 51 54 54 52 55 56 55 58 61 61 63 62 65 62 63 65 68 69 67 70 71 72 71 76 74 75 75 76 79 82 79 81 81 82 83 87 89 88 89 89 91 92 94 93 95 95 99 100 ...
output:
10
result:
ok single line: '10'
Test #68:
score: 25
Accepted
time: 403ms
memory: 252076kb
input:
200000 1 1 1 3 2 2 3 6 4 3 6 9 5 7 14 9 9 10 12 14 16 21 21 19 17 20 24 21 21 29 26 28 27 29 32 32 31 30 34 38 37 41 42 36 43 42 41 42 44 48 48 51 50 46 50 54 50 57 52 55 53 54 55 58 61 61 63 63 66 67 66 69 68 69 73 72 73 76 76 79 75 79 79 78 77 85 86 80 82 82 88 89 85 90 93 93 90 92 92 96 93 95 95 ...
output:
9
result:
ok single line: '9'
Test #69:
score: 25
Accepted
time: 390ms
memory: 252088kb
input:
200000 1 1 2 2 4 3 1 4 2 9 4 7 10 5 14 5 14 16 9 12 9 18 18 13 17 17 25 16 16 17 25 19 29 25 27 35 23 36 26 36 33 36 42 42 41 37 35 45 39 38 45 50 52 41 41 54 50 44 46 47 58 55 61 60 53 53 60 58 68 64 68 65 62 70 64 64 72 71 65 68 72 78 72 75 75 79 83 86 75 81 83 87 90 84 93 87 83 89 98 88 100 93 91...
output:
10
result:
ok single line: '10'
Test #70:
score: 25
Accepted
time: 111ms
memory: 218112kb
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:
200000
result:
ok single line: '200000'
Test #71:
score: 25
Accepted
time: 327ms
memory: 237664kb
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:
11
result:
ok single line: '11'
Test #72:
score: 25
Accepted
time: 319ms
memory: 236436kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
10
result:
ok single line: '10'
Test #73:
score: 25
Accepted
time: 364ms
memory: 245276kb
input:
200000 1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 ...
output:
11
result:
ok single line: '11'
Test #74:
score: 25
Accepted
time: 9ms
memory: 40132kb
input:
3000 1 1 1 3 4 4 5 6 8 9 10 11 12 13 14 15 15 17 17 18 20 20 22 23 23 24 25 26 28 28 30 30 32 32 34 35 35 36 38 38 40 41 42 43 43 45 45 47 48 49 49 50 52 52 53 54 56 57 57 59 60 60 62 63 63 65 66 67 68 69 69 70 71 73 74 74 76 77 78 79 79 81 81 82 83 84 85 87 88 88 89 90 92 92 94 94 95 96 98 98 100 1...
output:
2040
result:
ok single line: '2040'
Test #75:
score: 25
Accepted
time: 465ms
memory: 267752kb
input:
200000 1 1 1 3 4 5 5 7 8 8 9 11 11 13 14 14 16 16 17 18 20 21 21 22 24 25 26 26 28 28 29 31 31 33 34 34 35 37 37 39 40 40 42 42 43 45 45 47 47 48 49 50 52 53 54 55 56 56 58 59 59 61 62 63 63 65 66 66 68 68 69 70 71 73 73 75 76 77 77 79 79 81 81 83 83 85 86 87 87 89 90 91 92 92 93 94 96 96 97 98 100 ...
output:
134559
result:
ok single line: '134559'
Test #76:
score: 25
Accepted
time: 446ms
memory: 271644kb
input:
200000 1 1 2 2 3 4 5 6 7 9 10 11 12 13 14 14 15 17 18 19 19 21 22 23 23 24 25 27 28 29 29 31 32 33 33 35 35 36 38 39 40 41 42 42 44 44 45 47 48 49 50 51 51 53 53 54 56 57 58 59 60 60 61 63 64 65 66 66 67 68 69 71 72 72 73 74 76 77 78 79 80 81 82 83 84 84 85 87 88 89 90 90 91 93 94 94 95 96 97 98 100...
output:
134537
result:
ok single line: '134537'
Test #77:
score: 25
Accepted
time: 465ms
memory: 271592kb
input:
200000 1 1 1 2 4 4 5 6 7 9 10 10 12 13 14 14 15 17 17 18 20 21 22 23 24 25 26 26 28 29 30 30 32 32 34 35 35 37 38 39 39 40 42 43 44 45 46 47 47 49 49 51 51 52 54 55 55 57 58 58 60 60 62 63 63 64 66 67 68 69 69 71 71 72 73 74 76 76 77 79 80 80 81 83 83 84 85 87 87 88 89 91 92 92 93 95 96 96 98 99 99 ...
output:
134994
result:
ok single line: '134994'
Test #78:
score: 25
Accepted
time: 7ms
memory: 41460kb
input:
3000 1 1 2 3 4 2 6 6 4 7 10 7 10 10 10 11 14 15 17 19 20 20 22 20 23 25 22 23 25 27 30 27 28 29 31 35 34 37 37 35 37 39 39 42 42 43 45 46 45 45 48 47 48 51 54 54 52 55 56 55 58 61 61 63 62 65 62 63 65 68 69 67 70 71 72 71 76 74 75 75 76 79 82 79 81 81 82 83 87 89 88 89 89 91 92 94 93 95 95 99 100 10...
output:
3988
result:
ok single line: '3988'
Test #79:
score: 25
Accepted
time: 3ms
memory: 40760kb
input:
3000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:
48
result:
ok single line: '48'
Test #80:
score: 25
Accepted
time: 143ms
memory: 229384kb
input:
200000 1 1 2 2 4 3 5 4 6 7 8 9 10 12 14 13 16 16 17 16 19 18 20 23 23 25 23 26 26 27 27 29 29 33 33 35 35 34 38 36 39 38 42 40 41 43 43 45 45 46 49 50 50 51 53 52 54 54 58 59 58 59 61 62 63 65 64 64 66 68 70 71 72 70 72 74 76 75 77 76 78 80 80 83 81 83 85 86 85 87 87 91 92 90 93 93 93 97 98 96 98 99...
output:
280167
result:
ok single line: '280167'
Test #81:
score: 25
Accepted
time: 124ms
memory: 222288kb
input:
200000 1 1 1 1 1 1 6 5 8 7 8 7 11 10 11 12 16 13 17 17 18 18 18 20 24 22 22 27 25 29 28 29 29 31 30 34 36 37 37 36 37 41 42 42 43 41 44 46 48 45 47 47 49 53 54 54 52 57 57 57 60 57 60 59 64 64 62 66 67 65 70 69 70 71 70 71 74 74 75 77 78 80 81 83 81 85 86 85 87 89 86 90 91 90 92 94 92 93 98 99 100 9...
output:
266784
result:
ok single line: '266784'
Test #82:
score: 25
Accepted
time: 129ms
memory: 221500kb
input:
200000 1 1 1 1 4 4 1 2 4 9 5 11 9 8 9 15 13 12 17 12 18 19 18 22 21 18 21 27 23 23 23 29 28 29 27 28 35 37 32 37 33 38 41 41 39 41 39 47 47 46 43 44 51 49 49 53 52 55 57 58 58 61 60 62 64 58 65 67 68 66 65 66 71 71 71 72 74 74 77 73 76 75 75 81 77 83 86 84 85 89 86 91 90 88 87 94 95 93 94 94 96 99 1...
output:
244467
result:
ok single line: '244467'
Test #83:
score: 25
Accepted
time: 143ms
memory: 217448kb
input:
200000 1 1 1 1 2 3 1 1 7 7 10 9 4 4 3 14 12 16 8 18 18 11 18 18 21 13 22 18 25 23 26 22 29 31 31 29 23 28 37 33 31 36 32 41 40 33 44 34 39 38 50 44 41 48 47 52 44 50 53 50 47 49 52 54 53 63 63 59 55 60 67 62 62 69 66 62 72 70 66 78 76 80 77 77 74 80 84 74 75 81 81 88 83 88 82 86 84 96 90 96 88 92 10...
output:
226657
result:
ok single line: '226657'
Test #84:
score: 25
Accepted
time: 112ms
memory: 213144kb
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:
2102
result:
ok single line: '2102'
Test #85:
score: 25
Accepted
time: 123ms
memory: 229292kb
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:
299899
result:
ok single line: '299899'
Test #86:
score: 25
Accepted
time: 130ms
memory: 227220kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
299999
result:
ok single line: '299999'
Test #87:
score: 25
Accepted
time: 118ms
memory: 204532kb
input:
200000 1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 ...
output:
200016
result:
ok single line: '200016'
Test #88:
score: 25
Accepted
time: 10ms
memory: 41132kb
input:
3000 1 1 1 2 1 5 3 7 4 9 10 10 8 13 11 13 14 15 14 17 20 17 19 20 20 25 26 26 26 27 27 30 32 29 31 33 33 34 37 36 36 41 40 43 42 42 42 47 48 48 47 47 51 51 52 55 55 55 58 58 57 57 58 59 64 63 66 66 68 68 68 71 68 71 71 71 75 75 75 76 76 77 79 79 81 81 83 86 85 85 87 89 90 90 93 93 96 94 94 96 99 98 ...
output:
12
result:
ok single line: '12'
Test #89:
score: 25
Accepted
time: 480ms
memory: 271952kb
input:
200000 1 1 2 3 4 3 4 4 5 9 8 8 11 13 13 12 16 17 18 17 19 21 19 22 21 24 23 24 25 27 29 31 29 31 32 32 34 34 36 38 39 39 39 42 43 42 45 46 48 48 48 49 50 52 52 53 54 54 58 56 60 59 62 60 61 62 64 66 68 68 68 68 72 73 72 75 76 77 78 78 77 80 79 81 81 84 84 85 86 86 89 91 91 93 91 95 94 94 96 97 98 10...
output:
20
result:
ok single line: '20'
Test #90:
score: 25
Accepted
time: 484ms
memory: 269556kb
input:
200000 1 1 1 3 2 2 4 5 7 8 7 10 8 10 10 14 14 17 17 17 20 18 19 21 24 23 22 26 25 29 27 30 30 33 31 35 34 34 35 39 36 41 42 40 40 41 42 44 47 47 47 49 48 53 50 53 53 53 58 59 57 58 60 60 63 62 66 64 66 66 66 67 71 71 72 71 75 77 75 76 76 81 82 82 82 83 86 84 87 89 90 89 89 89 94 94 96 94 94 99 96 98...
output:
18
result:
ok single line: '18'
Test #91:
score: 25
Accepted
time: 448ms
memory: 261452kb
input:
200000 1 1 2 2 4 3 1 4 2 3 4 9 6 8 14 13 12 12 17 12 19 18 20 19 23 21 19 22 22 23 23 29 25 29 33 35 31 34 34 36 35 38 42 36 37 39 43 41 41 42 45 46 46 51 49 52 54 54 58 55 54 55 57 58 63 61 60 64 62 68 70 71 72 66 68 70 72 75 73 76 78 80 76 83 77 83 81 86 81 87 87 91 92 86 93 93 93 93 94 96 94 95 9...
output:
21
result:
ok single line: '21'
Test #92:
score: 25
Accepted
time: 453ms
memory: 263096kb
input:
200000 1 1 1 1 1 1 5 7 4 9 8 10 11 3 14 9 11 14 12 19 11 18 11 13 18 21 22 21 18 25 25 28 27 28 26 28 33 25 31 29 37 36 37 31 39 34 43 40 46 43 50 41 51 51 50 46 46 44 48 59 52 55 49 51 52 54 60 54 55 63 64 70 60 63 64 63 71 71 70 76 74 73 80 70 75 81 78 74 85 84 89 89 92 91 89 82 84 89 94 94 98 91 ...
output:
19
result:
ok single line: '19'
Test #93:
score: 25
Accepted
time: 367ms
memory: 313720kb
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:
8
result:
ok single line: '8'
Test #94:
score: 25
Accepted
time: 433ms
memory: 291336kb
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:
16
result:
ok single line: '16'
Test #95:
score: 25
Accepted
time: 427ms
memory: 281644kb
input:
200000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
50167
result:
ok single line: '50167'
Test #96:
score: 25
Accepted
time: 424ms
memory: 261760kb
input:
200000 1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 ...
output:
21
result:
ok single line: '21'
Subtask #7:
score: 14
Accepted
Test #97:
score: 14
Accepted
time: 1282ms
memory: 469996kb
input:
200000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
100667
result:
ok single line: '100667'
Test #98:
score: 14
Accepted
time: 1241ms
memory: 469864kb
input:
200000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
100213
result:
ok single line: '100213'
Test #99:
score: 14
Accepted
time: 24ms
memory: 41424kb
input:
200000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
-1
result:
ok single line: '-1'
Test #100:
score: 14
Accepted
time: 67ms
memory: 50856kb
input:
200000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
-1
result:
ok single line: '-1'
Test #101:
score: 14
Accepted
time: 60ms
memory: 48308kb
input:
200000 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
-1
result:
ok single line: '-1'
Test #102:
score: 14
Accepted
time: 63ms
memory: 46632kb
input:
200000 1 1 2 2 3 1 1 7 5 6 8 5 3 1 14 10 14 8 6 13 5 21 11 11 18 1 3 11 2 3 18 11 2 12 1 26 4 27 2 3 29 23 1 35 31 15 15 31 32 29 22 17 19 42 1 4 54 44 26 10 1 33 9 62 62 37 24 21 9 2 12 28 3 41 48 61 19 32 76 51 52 78 23 26 74 63 61 12 31 85 17 88 11 69 53 69 11 96 97 54 73 90 78 15 7 77 9 84 44 6 ...
output:
-1
result:
ok single line: '-1'
Test #103:
score: 14
Accepted
time: 10ms
memory: 38860kb
input:
200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
-1
result:
ok single line: '-1'
Test #104:
score: 14
Accepted
time: 516ms
memory: 317564kb
input:
200000 126615 1 1 2 4 3 5 3 7 6 6 11 11 13 14 14 12 13 14 19 18 19 20 23 22 23 23 23 25 29 27 28 28 32 30 31 32 34 35 39 38 38 41 42 41 41 44 47 44 47 47 49 49 53 50 53 52 56 57 58 57 60 62 63 64 63 62 63 67 67 68 69 69 72 73 71 72 73 76 79 79 79 79 83 80 82 85 83 87 86 88 87 88 90 91 91 95 96 97 99...
output:
9
result:
ok single line: '9'
Test #105:
score: 14
Accepted
time: 487ms
memory: 296328kb
input:
200000 132865 1 2 3 2 2 1 1 1 3 4 4 11 10 8 10 14 10 14 12 16 16 22 23 21 22 19 27 25 25 28 26 32 33 28 32 29 30 34 35 36 37 41 41 43 38 43 44 42 42 49 48 52 47 52 52 51 56 58 53 56 58 62 57 58 60 62 67 64 63 66 68 67 73 74 74 69 73 78 74 79 77 80 79 77 82 79 87 84 85 84 91 88 87 88 91 93 94 98 93 9...
output:
9
result:
ok single line: '9'
Test #106:
score: 14
Accepted
time: 12ms
memory: 40016kb
input:
3000 2918 513 1199 363 1715 2067 2546 955 37 113 2939 475 2292 899 2088 2378 873 171 388 2361 1105 882 2002 1222 1657 881 250 1646 1617 1974 149 419 1876 1426 1587 1204 361 608 152 1343 1933 1218 2025 404 1989 2696 1187 2982 923 1960 1427 2398 2730 684 2252 2294 1444 1919 2456 1065 2965 2896 1830 17...
output:
2020
result:
ok single line: '2020'
Test #107:
score: 14
Accepted
time: 708ms
memory: 317000kb
input:
200000 181306 36021 71980 127058 190188 74712 31027 2588 7922 37853 61715 3116 55095 189913 37940 146370 70406 194402 198360 100859 176275 168936 34740 194732 70716 170811 7396 116589 99733 132666 144901 108588 188545 163098 148422 185580 61049 2432 130956 42422 188185 175787 42589 47915 49095 36312...
output:
134656
result:
ok single line: '134656'
Test #108:
score: 14
Accepted
time: 680ms
memory: 306804kb
input:
200000 172680 149482 196031 35345 53363 60397 152278 95729 67772 33576 142493 182048 63892 146922 184846 177757 106783 128808 145885 149430 197643 15129 37203 193832 22476 159815 169124 52412 105318 86506 137541 89753 163111 30565 79606 58644 144215 21571 102186 196562 164639 118333 129817 175883 16...
output:
134640
result:
ok single line: '134640'
Test #109:
score: 14
Accepted
time: 667ms
memory: 322048kb
input:
200000 118096 55617 11369 53610 99027 1949 64656 110488 79392 39656 77115 144848 32699 69637 30416 763 156827 66989 40097 49513 123693 136239 192959 17774 149395 150446 154189 8417 12747 7567 83094 115870 153546 2595 29874 142060 1970 128804 189447 188666 178041 15875 67802 70458 168393 99 30632 146...
output:
134366
result:
ok single line: '134366'
Test #110:
score: 14
Accepted
time: 344ms
memory: 460832kb
input:
200000 166313 1 1 3 2 3 6 3 7 6 7 10 10 13 11 15 12 17 17 19 18 20 22 20 24 23 26 27 25 26 27 28 28 33 33 31 36 33 35 39 39 38 38 43 40 41 43 44 46 46 49 51 49 51 54 54 52 55 54 56 56 60 62 63 64 61 63 65 67 66 67 67 69 73 72 75 74 74 74 75 79 78 79 83 83 82 84 86 87 88 89 87 92 93 94 94 92 96 94 99...
output:
266627
result:
ok single line: '266627'
Test #111:
score: 14
Accepted
time: 340ms
memory: 467072kb
input:
200000 21387 1 1 1 3 1 4 1 3 6 9 9 5 12 14 10 12 13 12 18 13 21 15 22 22 19 24 26 25 29 30 27 32 28 27 31 36 31 33 33 39 34 35 37 41 44 40 46 44 47 44 45 50 53 50 51 53 56 57 54 60 58 61 62 63 61 66 65 68 64 70 67 70 72 70 73 69 71 74 78 73 75 80 82 77 78 84 85 87 85 89 85 89 90 93 94 92 95 93 95 93...
output:
244552
result:
ok single line: '244552'
Test #112:
score: 14
Accepted
time: 520ms
memory: 448496kb
input:
200000 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 92 91 94 93 96 95 98 97 100 99 1...
output:
11
result:
ok single line: '11'
Test #113:
score: 14
Accepted
time: 611ms
memory: 371240kb
input:
200000 132865 1 2 3 2 2 6 6 7 6 10 10 9 11 11 12 16 13 18 15 16 19 21 21 22 25 24 23 27 28 30 27 30 31 31 35 35 33 37 39 40 39 42 40 44 43 45 43 47 48 48 47 52 50 52 51 56 56 55 59 58 59 59 61 60 63 62 67 65 69 69 69 69 70 70 75 75 77 75 78 76 78 80 82 80 82 85 85 88 87 87 90 92 92 90 94 94 97 97 96...
output:
19
result:
ok single line: '19'
Test #114:
score: 14
Accepted
time: 594ms
memory: 358376kb
input:
200000 153497 1 1 2 3 3 2 5 1 5 3 6 7 10 14 9 16 14 15 18 19 17 18 18 22 23 25 22 21 23 27 31 28 29 29 28 35 31 32 35 39 35 39 41 42 41 39 45 44 48 45 45 50 50 48 55 54 50 55 57 60 57 62 60 61 59 60 63 62 67 66 69 69 66 67 69 70 76 75 78 77 78 82 76 78 82 84 83 83 83 90 85 91 86 90 95 96 95 98 94 98...
output:
24
result:
ok single line: '24'
Extra Test:
score: 0
Extra Test Passed