QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140021#1241. RaidXY_ElevenTL 2835ms112108kbC++234.5kb2023-08-14 23:26:242023-08-14 23:26:25

Judging History

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

  • [2023-08-14 23:26:25]
  • 评测
  • 测评结果:TL
  • 用时:2835ms
  • 内存:112108kb
  • [2023-08-14 23:26:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(3)
#define DB double
#define LL long long
#define ULL unsigned long long
#define pii pair<int,int>
#define pil pair<int,LL>
#define mii map<int,int>
#define miig map<int,int,greater<int> >
#define mil map<int,LL>
#define in128 __int128
#define cint const int
#define cLL const LL
#define cDB const DB
#define cchar const char
#define invoid inline void
#define inLL inline LL
#define inlint inline int
#define inbool inline bool
#define inl128 inline __int128
#define inDB inline double
#define For(z,e1,e2) for(int z=(e1);z<=(e2);z++)
#define Rof(z,e1,e2) for(int z=(e2);z>=(e1);z--)
#define For_(z,e1,e2) for(int z=(e1);z<(e2);z++)
#define Rof_(z,e1,e2) for(int z=(e2);z>(e1);z--)
#define inint(e) scanf("%d",&e)
#define inll(e) scanf("%lld",&e)
#define inpr(e1,e2) scanf("%d%d",&e1,&e2)
#define in3(e1,e2,e3) scanf("%d%d%d",&e1,&e2,&e3)
#define outint(e) printf("%d\n",e)
#define outint_(e) printf("%d%c",e," \n"[i==n])
#define outll(e) printf("%lld\n",e)
#define outll_(e) printf("%lld%c",e," \n"[i==n])
#define exc(e) if(e) continue
#define stop(e) if(e) break
#define ret(e) if(e) return
#define ll(e) ((LL)(e))
#define pb push_back
#define ft first
#define sc second
#define clean(e) while(!e.empty()) e.pop()
#define all(ev) ev.begin(),ev.end()
#define x0 x00
#define y1 y11
#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define fout fflush(stdout)
invoid input(int &N_,int A_[],bool F_)
{
    if(F_) inint(N_);
    For(i,1,N_) inint(A_[i]);
}
template <typename Type>
inline Type md(Type w1,const Type w2)
{
    w1%=w2; if(w1<0) w1+=w2;
    return w1;
}
template <typename Type>
invoid add(Type &w1,const Type w2,const Type M_)
{ w1=md(w1+w2,M_); }
invoid mul(LL &w1,cLL w2,cLL M_)
{ w1=md(w1*w2,M_); }
inLL gcd(LL X_,LL Y_)
{
    LL R_=X_%Y_;
    while(R_)
    { X_=Y_; Y_=R_; R_=X_%Y_; }
    return Y_;
}
invoid ex_gcd(LL &X_,LL &Y_,LL A_,LL B_)
{
    if(!B_)
    {
        X_=1ll; Y_=0ll;
        return ;
    }
    ex_gcd(Y_,X_,B_,A_%B_);
    X_=md(X_,B_); Y_=(1ll-X_*A_)/B_;
}
inLL inv(LL A_,LL B_)
{
    LL X_=0ll,Y_=0ll;
    ex_gcd(X_,Y_,A_,B_);
    return X_;
}
inLL pw(LL X_,LL Y_,LL M_)
{
    LL S_=1ll;
    while(Y_)
    {
        if(Y_&1) mul(S_,X_,M_);
        Y_>>=1;
        mul(X_,X_,M_);
    }
    return S_;
}
template <typename Type>
invoid get_min(Type &w1,const Type w2)
{ if(w2<w1) w1=w2; }
template <typename Type>
invoid get_max(Type &w1,const Type w2)
{ if(w2>w1) w1=w2; }
//inLL A(cint N_,cint M_)
//{ return (N_>=M_?md(d1[N_]*d2[N_-M_],mod):0ll); }
//inLL C(cint N_,cint M_)
//{ return (N_>=M_?md(d1[N_]*md(d2[M_]*d2[N_-M_],mod),mod):0ll); }
//mt19937 gen(time(NULL));
//mt19937_64 gen(time(NULL));
//cLL base[]={166686661,188868881},mod[]={1686688681,1666868881};
//cLL base[]={166686661,188868881},mod[]={1686688681,1666868881},inter=1861;
//cLL mod[]={1e9+7,1e9+9,1e9+21,1e9+33};
//cLL mod=998244353;
cint N=50;
int n;
int a[N],rk[N][N];
map <vector <int>,pair<int,LL> > dp[N];
vector <int> c,t;
int main()
{
    inint(n);
    For(i,1,n) inint(a[i]),a[i]=n-a[i]+1;
//    n=40;
//    For(i,1,n) a[i]=i,swap(a[i],a[rand()%i+1]);
    For(i,1,n) For(j,i,n) For(k,j+1,n)
        rk[i][j]+=(a[k]<a[j]);
    For(i,0,n) t.pb(0);
    dp[0][t]={0ll,1ll};
    int ans=1e9;
    LL sum=0ll;
    For(v,1,n)
    {
//        debug(v);
        for(auto [x,g]:dp[v-1])
        {
//            puts("start");
            t=x;
            For(i,n+2-(int)t.size(),n)
            {
//                debug(i);
                c=t; t.clear();
                int s=g.ft+c[rk[i][i]];
                For_(j,0,rk[i][i])
                    t.pb(c[j]),
                    s+=c[j];
//                debug(s);
                t.pb(c[rk[i][i]]+c[rk[i][i]+1]+1);
                int siz=(int)c.size();
                For_(j,rk[i][i]+2,siz)
                    t.pb(c[j]);
                if(dp[v].find(t)==dp[v].end()||
                   dp[v][t].ft>s)
                    dp[v][t]={s,g.sc};
                else if(dp[v][t].ft==s)
                    dp[v][t].sc+=g.sc;
                t[rk[i][i]]--;
            }
        }
        ans=1e9;
        sum=0ll;
//        for(auto [x,g]:dp[v])
//            printf("# %d %lld\n",g.ft,g.sc);
        for(auto [x,g]:dp[v])
            if(g.ft<ans) ans=g.ft,sum=g.sc;
            else if(g.ft==ans) sum+=g.sc;
        printf("%d %lld\n",ans,sum);
    }
    return 0;
}
/*

*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3776kb

input:

5
5 3 1 4 2

output:

0 5
0 3
1 2
3 1
7 1

result:

ok 10 numbers

Test #2:

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

input:

1
1

output:

0 1

result:

ok 2 number(s): "0 1"

Test #3:

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

input:

2
1 2

output:

0 2
0 1

result:

ok 4 number(s): "0 2 0 1"

Test #4:

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

input:

3
2 1 3

output:

0 3
0 2
1 1

result:

ok 6 numbers

Test #5:

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

input:

4
3 1 2 4

output:

0 4
0 4
0 1
2 1

result:

ok 8 numbers

Test #6:

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

input:

5
1 2 5 4 3

output:

0 5
0 7
0 3
1 3
3 1

result:

ok 10 numbers

Test #7:

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

input:

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

output:

0 18
0 78
0 132
0 104
0 38
0 5
1 2
3 6
5 1
9 8
12 1
17 1
25 4
33 5
41 2
50 1
61 1
75 1

result:

ok 36 numbers

Test #8:

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

input:

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

output:

0 18
0 76
0 141
0 139
0 78
0 24
0 3
1 2
3 3
5 1
10 3
15 1
22 1
30 1
40 1
52 3
64 2
77 1

result:

ok 36 numbers

Test #9:

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

input:

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

output:

0 18
0 86
0 190
0 223
0 154
0 60
0 10
1 12
2 2
4 4
6 1
9 1
15 3
21 1
29 1
39 1
50 1
67 1

result:

ok 36 numbers

Test #10:

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

input:

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

output:

0 18
0 153
0 816
0 3060
0 8568
0 18564
0 31824
0 43758
0 48620
0 43758
0 31824
0 18564
0 8568
0 3060
0 816
0 153
0 18
0 1

result:

ok 36 numbers

Test #11:

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

input:

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

output:

0 18
1 153
3 816
6 3060
10 8568
15 18564
21 31824
28 43758
36 48620
45 43758
55 31824
66 18564
78 8568
91 3060
105 816
120 153
136 18
153 1

result:

ok 36 numbers

Test #12:

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

input:

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

output:

0 18
0 85
0 150
0 115
0 42
0 6
1 9
2 3
4 1
7 1
11 2
16 2
22 2
29 2
37 2
46 2
56 1
68 1

result:

ok 36 numbers

Test #13:

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

input:

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

output:

0 18
0 64
0 89
0 55
0 16
0 2
1 1
3 1
6 1
10 2
15 5
20 1
27 1
35 1
45 1
57 1
72 1
89 1

result:

ok 36 numbers

Test #14:

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

input:

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

output:

0 18
0 88
0 163
0 127
0 43
0 4
1 4
2 1
4 1
7 1
11 2
15 1
20 1
27 1
35 3
43 1
53 1
65 1

result:

ok 36 numbers

Test #15:

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

input:

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

output:

0 18
0 67
0 83
0 36
0 4
1 2
3 2
6 5
9 2
13 3
18 3
24 3
31 3
39 3
48 2
58 1
70 1
86 1

result:

ok 36 numbers

Test #16:

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

input:

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

output:

0 18
0 147
0 720
0 2355
0 5418
0 8989
0 10836
0 9420
0 5760
0 2352
0 576
0 64
1 192
2 240
3 160
4 60
5 12
6 1

result:

ok 36 numbers

Test #17:

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

input:

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

output:

0 18
0 117
0 408
0 882
0 1260
0 1218
0 792
0 333
0 82
0 9
1 8
3 7
6 6
10 5
15 4
21 3
28 2
36 1

result:

ok 36 numbers

Test #18:

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

input:

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

output:

0 18
0 45
1 240
2 210
4 504
6 210
9 240
12 45
16 20
20 1
26 2
33 1
42 2
52 1
64 2
77 1
92 2
108 1

result:

ok 36 numbers

Test #19:

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

input:

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

output:

0 18
0 59
0 92
0 71
0 26
0 5
1 4
3 3
6 2
10 1
20 8
30 24
40 32
50 16
61 36
71 3
82 2
94 1

result:

ok 36 numbers

Test #20:

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

input:

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

output:

0 18
0 62
0 108
0 97
0 36
1 83
2 80
3 40
4 10
5 1
15 8
25 22
35 28
45 17
55 4
66 3
78 2
91 1

result:

ok 36 numbers

Test #21:

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

input:

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

output:

0 23
0 135
0 324
0 384
0 235
0 70
0 8
1 12
2 6
3 1
6 4
9 4
12 1
17 4
22 4
27 1
36 1
46 1
57 2
69 1
85 2
101 1
118 1

result:

ok 46 numbers

Test #22:

score: 0
Accepted
time: 8ms
memory: 4232kb

input:

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

output:

0 23
0 105
0 204
0 237
0 171
0 75
0 19
0 2
1 1
3 2
5 1
9 1
14 1
22 2
30 1
40 2
50 1
63 3
77 4
92 3
108 1
126 1
148 1

result:

ok 46 numbers

Test #23:

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

input:

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

output:

0 23
0 174
0 515
0 714
0 486
0 146
0 12
1 16
2 7
3 1
5 2
8 5
11 3
15 7
19 4
24 8
29 4
35 3
42 4
49 1
57 1
67 1
79 1

result:

ok 46 numbers

Test #24:

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

input:

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

output:

0 23
0 253
0 1771
0 8855
0 33649
0 100947
0 245157
0 490314
0 817190
0 1144066
0 1352078
0 1352078
0 1144066
0 817190
0 490314
0 245157
0 100947
0 33649
0 8855
0 1771
0 253
0 23
0 1

result:

ok 46 numbers

Test #25:

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

input:

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

output:

0 23
1 253
3 1771
6 8855
10 33649
15 100947
21 245157
28 490314
36 817190
45 1144066
55 1352078
66 1352078
78 1144066
91 817190
105 490314
120 245157
136 100947
153 33649
171 8855
190 1771
210 253
231 23
253 1

result:

ok 46 numbers

Test #26:

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

input:

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

output:

0 23
0 149
0 422
0 622
0 501
0 210
0 36
1 70
2 40
3 5
5 4
8 8
11 4
15 9
19 4
24 3
30 1
39 3
48 1
59 1
73 2
88 2
104 1

result:

ok 46 numbers

Test #27:

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

input:

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

output:

0 23
0 104
0 164
0 109
0 30
0 2
1 1
3 6
5 3
8 7
11 1
16 3
21 1
28 1
37 4
46 1
57 4
68 1
81 1
95 1
110 1
128 1
149 1

result:

ok 46 numbers

Test #28:

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

input:

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

output:

0 23
0 148
0 407
0 578
0 454
0 197
0 44
0 4
1 2
3 3
5 1
8 4
11 4
14 1
18 1
23 1
31 2
39 1
50 1
62 1
76 4
90 2
105 1

result:

ok 46 numbers

Test #29:

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

input:

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

output:

0 23
0 107
0 178
0 124
0 36
0 4
1 3
3 7
5 5
7 1
11 1
16 3
22 7
28 2
35 1
44 1
55 3
66 1
78 1
92 1
108 2
124 1
146 1

result:

ok 46 numbers

Test #30:

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

input:

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

output:

0 23
0 5
2 105
4 10
8 190
12 10
18 170
24 5
32 75
40 1
50 13
61 78
73 286
86 715
100 1287
115 1716
131 1716
148 1287
166 715
185 286
205 78
226 13
248 1

result:

ok 46 numbers

Test #31:

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

input:

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

output:

0 23
0 187
0 825
0 2310
0 4422
0 6006
0 5874
0 4125
0 2035
0 671
0 133
0 12
1 11
3 10
6 9
10 8
15 7
21 6
28 5
36 4
45 3
55 2
66 1

result:

ok 46 numbers

Test #32:

score: 0
Accepted
time: 44ms
memory: 5616kb

input:

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

output:

0 23
0 66
1 440
2 495
4 1584
6 924
9 1584
12 495
16 440
20 66
25 24
30 1
37 2
45 1
55 2
66 1
79 2
93 1
109 2
126 1
145 2
165 1
187 1

result:

ok 46 numbers

Test #33:

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

input:

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

output:

0 23
0 101
0 230
0 295
0 208
0 69
0 6
1 5
3 44
4 10
5 1
15 1
27 62
38 110
49 135
60 96
71 37
82 6
94 5
107 4
121 3
136 2
152 1

result:

ok 46 numbers

Test #34:

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

input:

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

output:

0 23
0 107
0 280
0 455
0 458
0 261
0 64
1 192
2 240
3 160
4 60
5 12
6 1
19 10
32 35
45 60
58 55
71 26
84 5
98 4
113 3
129 2
146 1

result:

ok 46 numbers

Test #35:

score: 0
Accepted
time: 37ms
memory: 5832kb

input:

26
7 2 16 21 23 4 1 5 12 24 13 14 8 18 10 3 11 6 22 17 19 20 9 15 25 26

output:

0 26
0 210
0 814
0 1800
0 2503
0 2326
0 1495
0 667
0 199
0 36
0 3
1 1
3 1
6 2
9 1
13 3
17 3
21 1
26 1
34 1
43 1
53 1
66 1
80 1
97 1
115 1

result:

ok 52 numbers

Test #36:

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

input:

26
23 19 21 18 2 4 7 8 5 9 16 12 11 25 20 17 10 26 24 6 15 3 14 1 22 13

output:

0 26
0 161
0 478
0 865
0 947
0 600
0 201
0 27
1 71
2 49
3 9
5 15
7 7
9 1
13 1
19 5
25 3
32 1
41 1
53 1
68 2
84 2
101 1
120 1
141 1
164 1

result:

ok 52 numbers

Test #37:

score: 0
Accepted
time: 18ms
memory: 4900kb

input:

26
5 10 2 17 19 7 8 6 20 11 1 3 22 4 23 14 24 16 9 12 15 25 26 18 21 13

output:

0 26
0 219
0 809
0 1570
0 1760
0 1185
0 477
0 112
0 15
0 1
2 2
4 1
7 1
10 2
13 1
18 3
23 1
29 2
35 1
42 1
50 2
58 1
68 2
79 1
92 1
106 1

result:

ok 52 numbers

Test #38:

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

input:

26
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

output:

0 26
0 325
0 2600
0 14950
0 65780
0 230230
0 657800
0 1562275
0 3124550
0 5311735
0 7726160
0 9657700
0 10400600
0 9657700
0 7726160
0 5311735
0 3124550
0 1562275
0 657800
0 230230
0 65780
0 14950
0 2600
0 325
0 26
0 1

result:

ok 52 numbers

Test #39:

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

input:

26
26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

0 26
1 325
3 2600
6 14950
10 65780
15 230230
21 657800
28 1562275
36 3124550
45 5311735
55 7726160
66 9657700
78 10400600
91 9657700
105 7726160
120 5311735
136 3124550
153 1562275
171 657800
190 230230
210 65780
231 14950
253 2600
276 325
300 26
325 1

result:

ok 52 numbers

Test #40:

score: 0
Accepted
time: 206ms
memory: 14524kb

input:

26
7 2 9 11 4 14 16 26 24 18 21 1 5 12 19 22 25 8 15 3 10 17 23 6 20 13

output:

0 26
0 188
0 595
0 999
0 999
0 637
0 262
0 66
0 8
1 12
2 6
3 1
6 1
10 2
14 1
19 1
25 1
32 1
41 1
51 2
61 1
72 1
86 1
102 2
119 2
137 1

result:

ok 52 numbers

Test #41:

score: 0
Accepted
time: 117ms
memory: 8728kb

input:

26
14 7 20 11 23 3 17 25 5 9 21 18 16 1 13 24 19 26 22 15 10 4 12 8 2 6

output:

0 26
0 139
0 273
0 254
0 105
0 14
1 21
2 6
4 11
6 6
8 1
11 1
15 4
19 1
25 1
33 1
43 4
53 2
64 1
77 1
91 1
106 1
124 1
143 1
163 1
186 1

result:

ok 52 numbers

Test #42:

score: 0
Accepted
time: 41ms
memory: 6504kb

input:

26
2 13 21 1 19 6 25 12 3 23 7 17 4 26 11 14 20 5 15 24 8 16 22 9 18 10

output:

0 26
0 184
0 560
0 885
0 793
0 408
0 110
0 12
1 20
2 11
3 2
5 1
8 4
11 1
15 1
20 1
27 4
34 1
43 2
53 3
64 2
76 1
90 1
105 1
123 2
141 1

result:

ok 52 numbers

Test #43:

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

input:

26
14 26 7 22 15 3 24 10 25 5 12 23 1 19 8 21 6 18 13 2 20 11 4 17 9 16

output:

0 26
0 138
0 238
0 156
0 33
1 66
2 33
3 1
5 1
8 6
11 2
15 3
19 1
24 1
31 3
38 1
47 2
57 2
68 2
80 1
94 1
109 1
126 1
144 1
163 1
187 1

result:

ok 52 numbers

Test #44:

score: 0
Accepted
time: 143ms
memory: 11924kb

input:

26
1 25 13 19 7 16 10 4 22 23 2 14 8 11 17 26 5 20 3 15 18 21 12 9 24 6

output:

0 26
0 171
0 495
0 765
0 690
0 373
0 114
0 15
1 25
2 10
4 23
6 15
8 3
11 1
16 1
22 1
29 1
38 5
47 2
58 5
69 1
82 1
97 3
112 1
131 1
154 1

result:

ok 52 numbers

Test #45:

score: 0
Accepted
time: 122ms
memory: 9992kb

input:

26
20 24 2 12 16 14 8 22 26 10 6 18 4 13 7 25 5 21 19 3 11 15 17 9 1 23

output:

0 26
0 146
0 320
0 335
0 176
0 45
0 5
1 3
3 4
6 16
9 15
12 2
16 1
21 1
28 11
34 2
41 1
50 2
60 1
72 2
85 1
100 2
116 1
134 1
155 1
179 1

result:

ok 52 numbers

Test #46:

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

input:

26
2 1 3 4 5 6 8 7 9 10 12 11 13 14 16 15 17 18 19 20 22 21 24 23 26 25

output:

0 26
0 318
0 2432
0 13039
0 52074
0 160664
0 391912
0 767103
0 1215566
0 1566070
0 1640640
0 1392065
0 948430
0 511380
0 213272
0 66352
0 14496
0 1984
0 128
1 448
2 672
3 560
4 280
5 84
6 14
7 1

result:

ok 52 numbers

Test #47:

score: 0
Accepted
time: 126ms
memory: 11496kb

input:

26
1 4 7 10 13 16 19 22 25 2 5 8 11 14 17 20 23 26 3 6 9 12 15 18 21 24

output:

0 26
0 217
0 920
0 2338
0 3836
0 4186
0 3032
0 1405
0 378
0 45
1 72
2 28
4 42
6 15
9 20
12 6
16 6
20 1
26 2
33 1
42 2
52 1
64 2
77 1
92 2
108 1

result:

ok 52 numbers

Test #48:

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

input:

26
1 14 2 15 3 16 4 17 5 18 6 19 7 20 8 21 9 22 10 23 11 24 12 25 13 26

output:

0 26
0 247
0 1300
0 4433
0 10582
0 18447
0 24024
0 23595
0 17446
0 9581
0 3796
0 1027
0 170
0 13
1 12
3 11
6 10
10 9
15 8
21 7
28 6
36 5
45 4
55 3
66 2
78 1

result:

ok 52 numbers

Test #49:

score: 0
Accepted
time: 172ms
memory: 9308kb

input:

26
25 23 21 19 17 15 13 11 9 7 5 3 1 26 24 22 20 18 16 14 12 10 8 6 4 2

output:

0 26
0 91
1 728
2 1001
4 4004
6 3003
9 6864
12 3003
16 4004
20 1001
25 728
30 91
36 28
42 1
50 2
59 1
70 2
82 1
96 2
111 1
128 2
146 1
166 2
187 1
210 2
234 1

result:

ok 52 numbers

Test #50:

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

input:

26
13 20 14 21 15 22 16 23 17 24 18 25 19 26 2 1 4 3 6 5 8 7 10 9 12 11

output:

0 26
0 130
0 342
0 520
0 458
0 218
0 50
0 7
1 6
3 5
5 12
6 1
15 2
21 1
35 12
49 60
63 160
77 240
90 50
102 7
115 6
129 5
144 4
160 3
177 2
195 1

result:

ok 52 numbers

Test #51:

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

input:

26
15 21 16 22 17 23 18 24 19 25 20 26 2 1 4 3 6 5 8 7 10 9 12 11 14 13

output:

0 26
0 135
0 390
0 695
0 768
0 485
0 134
1 453
2 672
3 560
4 280
5 84
6 14
7 1
21 12
35 51
49 110
63 135
77 96
91 37
105 6
120 5
136 4
153 3
171 2
190 1

result:

ok 52 numbers

Test #52:

score: 0
Accepted
time: 292ms
memory: 15496kb

input:

30
2 27 28 16 5 9 24 23 4 13 25 11 30 18 21 19 15 26 29 10 7 22 14 17 12 8 20 3 1 6

output:

0 30
0 176
0 467
0 659
0 517
0 222
0 48
0 4
1 4
2 1
4 2
6 1
9 1
13 1
19 2
25 1
33 2
42 3
52 4
63 4
75 3
88 1
103 4
118 1
137 1
159 3
181 1
205 1
231 1
259 1

result:

ok 60 numbers

Test #53:

score: 0
Accepted
time: 202ms
memory: 12992kb

input:

30
13 11 28 12 29 5 7 19 3 30 25 20 16 2 24 21 23 26 22 1 17 10 9 15 8 27 4 14 6 18

output:

0 30
0 191
0 417
0 435
0 274
0 108
0 23
0 2
2 12
4 23
6 15
8 2
11 1
15 1
21 2
27 1
35 1
44 1
54 3
64 1
76 1
89 2
103 1
119 3
135 1
153 1
174 2
195 1
219 1
244 1

result:

ok 60 numbers

Test #54:

score: 0
Accepted
time: 89ms
memory: 7836kb

input:

30
18 29 23 5 20 21 4 2 26 22 25 19 30 14 3 15 9 13 11 17 28 27 12 24 8 1 7 10 16 6

output:

0 30
0 171
0 348
0 284
0 108
0 14
1 20
2 6
4 11
6 3
9 3
12 1
16 2
20 1
26 1
35 3
45 6
56 10
67 1
79 9
90 1
103 2
117 1
133 1
151 1
170 2
190 1
213 1
237 1
264 1

result:

ok 60 numbers

Test #55:

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

input:

30
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

output:

0 30
0 435
0 4060
0 27405
0 142506
0 593775
0 2035800
0 5852925
0 14307150
0 30045015
0 54627300
0 86493225
0 119759850
0 145422675
0 155117520
0 145422675
0 119759850
0 86493225
0 54627300
0 30045015
0 14307150
0 5852925
0 2035800
0 593775
0 142506
0 27405
0 4060
0 435
0 30
0 1

result:

ok 60 numbers

Test #56:

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

input:

30
30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

0 30
1 435
3 4060
6 27405
10 142506
15 593775
21 2035800
28 5852925
36 14307150
45 30045015
55 54627300
66 86493225
78 119759850
91 145422675
105 155117520
120 145422675
136 119759850
153 86493225
171 54627300
190 30045015
210 14307150
231 5852925
253 2035800
276 593775
300 142506
325 27405
351 4060...

result:

ok 60 numbers

Test #57:

score: 0
Accepted
time: 1229ms
memory: 54208kb

input:

30
3 1 9 13 5 7 11 15 30 22 28 20 18 26 24 17 6 2 10 25 29 14 21 19 12 4 27 23 8 16

output:

0 30
0 255
0 979
0 2043
0 2490
0 1786
0 728
0 150
0 12
1 24
2 15
3 3
5 7
7 5
9 1
12 1
17 3
22 4
27 1
34 1
43 2
52 1
63 1
75 1
88 1
102 1
118 1
137 1
158 1
180 1

result:

ok 60 numbers

Test #58:

score: 0
Accepted
time: 667ms
memory: 22952kb

input:

30
16 8 24 20 4 12 28 26 14 2 18 22 10 6 29 30 27 25 23 19 13 7 21 17 9 11 15 1 3 5

output:

0 30
0 175
0 345
0 267
0 101
0 23
0 2
1 1
3 3
6 4
10 17
14 15
18 4
23 1
30 21
36 3
43 2
51 1
61 2
72 2
84 2
97 1
112 3
127 1
145 2
163 1
182 1
207 1
233 1
260 1

result:

ok 60 numbers

Test #59:

score: 0
Accepted
time: 60ms
memory: 6892kb

input:

30
5 18 2 26 1 19 7 29 3 17 10 25 6 20 12 30 8 21 4 27 9 22 11 28 13 23 14 24 15 16

output:

0 30
0 263
0 1040
0 2193
0 2665
0 1925
0 824
0 204
0 29
0 2
1 1
3 3
5 2
8 6
11 7
14 4
17 1
22 1
28 3
34 2
41 1
50 2
59 1
70 1
84 2
98 1
113 1
129 1
150 1
172 1

result:

ok 60 numbers

Test #60:

score: 0
Accepted
time: 65ms
memory: 8112kb

input:

30
15 29 7 26 14 23 3 28 12 27 6 25 13 24 1 30 11 22 5 20 9 18 2 19 10 17 4 16 8 21

output:

0 30
0 176
0 330
0 266
0 94
0 13
1 14
2 2
4 1
7 14
10 13
13 2
17 1
22 1
28 3
34 1
43 2
52 1
63 2
74 1
86 1
100 1
116 5
132 2
150 6
168 1
188 2
209 1
232 1
259 1

result:

ok 60 numbers

Test #61:

score: 0
Accepted
time: 702ms
memory: 36120kb

input:

30
15 27 6 9 24 3 30 21 18 12 4 25 22 13 10 7 19 16 28 1 17 11 29 5 20 8 23 26 2 14

output:

0 30
0 209
0 609
0 871
0 675
0 314
0 91
0 15
0 1
2 3
4 3
6 1
9 2
12 1
16 2
20 1
26 1
34 4
42 2
51 2
61 2
72 1
85 1
101 3
117 1
134 1
153 1
175 1
199 1
226 1

result:

ok 60 numbers

Test #62:

score: 0
Accepted
time: 845ms
memory: 35744kb

input:

30
1 7 25 21 13 19 17 23 3 5 11 29 27 9 15 4 16 24 30 18 20 2 22 10 28 12 14 26 6 8

output:

0 30
0 227
0 733
0 1315
0 1481
0 1115
0 575
0 199
0 42
0 4
1 4
2 1
4 1
7 1
11 1
16 1
22 2
29 1
38 4
47 2
57 2
68 2
80 1
94 1
109 3
124 1
143 2
163 1
185 1
208 1

result:

ok 60 numbers

Test #63:

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

input:

30
1 2 3 4 5 6 8 7 9 10 11 12 13 14 15 16 17 18 20 19 21 22 24 23 26 25 28 27 30 29

output:

0 30
0 429
0 3892
0 25152
0 123240
0 475780
0 1484640
0 3811230
0 8149460
0 14640774
0 22225800
0 28605356
0 31249128
0 28949028
0 22672832
0 14930505
0 8197758
0 3707509
0 1357284
0 392172
0 86080
0 13488
0 1344
0 64
1 192
2 240
3 160
4 60
5 12
6 1

result:

ok 60 numbers

Test #64:

score: 0
Accepted
time: 1336ms
memory: 56280kb

input:

30
3 1 10 5 12 7 16 18 14 21 24 30 26 28 8 19 22 29 15 11 2 25 6 20 13 27 4 23 9 17

output:

0 30
0 255
0 1020
0 2316
0 3226
0 2822
0 1525
0 482
0 83
0 6
1 7
2 2
4 5
6 4
8 1
11 4
14 2
18 1
24 1
31 1
40 3
49 1
60 1
73 3
86 2
100 1
118 1
137 1
157 1
180 1

result:

ok 60 numbers

Test #65:

score: 0
Accepted
time: 681ms
memory: 24568kb

input:

30
17 8 25 12 21 4 28 14 23 6 2 10 19 30 27 15 26 29 24 18 20 16 9 22 7 3 13 11 1 5

output:

0 30
0 179
0 384
0 355
0 156
0 31
0 2
2 12
4 16
6 4
9 12
12 7
15 1
20 4
25 3
31 3
38 1
47 6
55 1
64 1
75 1
89 1
104 1
121 1
139 1
158 1
179 1
203 1
228 1
256 1

result:

ok 60 numbers

Test #66:

score: 0
Accepted
time: 102ms
memory: 9224kb

input:

30
5 21 1 25 3 18 2 28 4 15 24 16 7 30 10 23 6 17 27 8 20 9 29 13 22 11 26 12 19 14

output:

0 30
0 253
0 937
0 1840
0 2148
0 1555
0 679
0 162
0 16
1 18
2 7
3 1
5 1
8 2
11 1
15 2
19 1
25 2
31 1
38 1
47 2
56 1
66 1
77 1
91 1
106 1
122 1
141 1
161 1
182 1

result:

ok 60 numbers

Test #67:

score: 0
Accepted
time: 103ms
memory: 8324kb

input:

30
29 8 30 16 4 28 12 23 2 25 13 27 5 24 11 21 1 22 10 26 6 20 9 19 3 18 15 7 17 14

output:

0 30
0 176
0 343
0 231
0 64
0 6
1 3
3 10
5 7
8 15
11 7
15 11
19 2
24 2
30 4
36 2
43 1
51 1
60 1
70 1
82 1
95 1
110 1
126 1
143 1
161 1
180 1
204 1
231 1
259 1

result:

ok 60 numbers

Test #68:

score: 0
Accepted
time: 1162ms
memory: 50564kb

input:

30
16 22 8 26 4 12 28 2 10 24 6 18 14 30 1 19 15 25 7 21 11 29 3 20 13 27 5 23 9 17

output:

0 30
0 223
0 638
0 847
0 553
0 157
1 535
2 672
3 377
4 92
5 8
7 4
10 16
13 20
16 8
19 1
26 1
34 4
42 6
50 4
58 1
70 1
83 2
96 1
113 3
130 1
149 2
169 2
190 2
212 1

result:

ok 60 numbers

Test #69:

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

input:

30
1 16 2 17 3 18 4 19 5 20 6 21 7 22 8 23 9 24 10 25 11 26 12 27 13 28 14 29 15 30

output:

0 30
0 330
0 2030
0 8190
0 23478
0 50050
0 81510
0 102960
0 101530
0 78078
0 46410
0 20930
0 6930
0 1590
0 226
0 15
1 14
3 13
6 12
10 11
15 10
21 9
28 8
36 7
45 6
55 5
66 4
78 3
91 2
105 1

result:

ok 60 numbers

Test #70:

score: 0
Accepted
time: 1002ms
memory: 27612kb

input:

30
29 27 25 23 21 19 17 15 13 11 9 7 5 3 1 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2

output:

0 30
0 120
1 1120
2 1820
4 8736
6 8008
9 22880
12 12870
16 22880
20 8008
25 8736
30 1820
36 1120
42 120
49 32
56 1
65 2
75 1
87 2
100 1
115 2
131 1
149 2
168 1
189 2
211 1
235 2
260 1
287 2
315 1

result:

ok 60 numbers

Test #71:

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

input:

30
13 22 14 23 15 24 16 25 17 26 18 27 19 28 20 29 21 30 2 1 4 3 6 5 8 7 10 9 12 11

output:

0 30
0 177
0 568
0 1122
0 1452
0 1282
0 792
0 333
0 82
0 9
1 8
3 7
6 6
10 5
15 4
21 3
28 2
36 1
54 12
72 60
90 160
108 240
126 192
144 64
163 192
182 240
201 164
219 3
238 2
258 1

result:

ok 60 numbers

Test #72:

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

input:

30
15 23 16 24 17 25 18 26 19 27 20 28 21 29 22 30 2 1 4 3 6 5 8 7 10 9 12 11 14 13

output:

0 30
0 176
0 560
0 1078
0 1288
0 924
0 360
0 65
0 8
1 7
3 6
5 84
6 14
7 1
21 18
28 1
44 14
60 84
76 280
91 476
105 232
119 65
133 8
148 7
164 6
181 5
199 4
218 3
238 2
259 1

result:

ok 60 numbers

Test #73:

score: 0
Accepted
time: 335ms
memory: 20364kb

input:

32
18 10 23 6 14 9 5 19 7 20 15 22 12 28 13 3 1 30 27 21 32 25 26 8 24 16 17 11 31 2 4 29

output:

0 32
0 278
0 1020
0 1890
0 1877
0 988
0 250
0 24
1 34
2 15
3 2
5 5
7 4
9 1
13 6
17 9
21 2
26 10
31 12
36 4
42 5
48 1
57 1
69 3
81 1
95 3
110 3
126 1
144 1
163 1
190 1
218 1

result:

ok 64 numbers

Test #74:

score: 0
Accepted
time: 551ms
memory: 25096kb

input:

32
26 30 21 10 18 31 20 15 6 22 13 1 24 12 28 9 27 25 5 7 16 14 8 3 29 2 23 4 19 32 11 17

output:

0 32
0 210
0 515
0 593
0 341
0 109
0 25
0 3
1 3
3 4
5 1
9 4
13 1
18 1
24 2
31 4
38 1
46 1
55 3
64 1
75 1
87 1
100 1
114 1
130 2
147 1
166 1
187 2
208 1
233 2
258 1
286 1

result:

ok 64 numbers

Test #75:

score: 0
Accepted
time: 85ms
memory: 7952kb

input:

32
6 19 15 10 30 27 20 7 14 1 2 8 16 18 17 11 21 5 24 9 23 13 22 28 3 32 29 26 12 31 4 25

output:

0 32
0 298
0 1336
0 3401
0 5290
0 5197
0 3237
0 1239
0 265
0 24
1 48
2 30
3 6
5 17
7 11
9 2
12 1
16 6
20 5
24 1
29 1
36 2
44 2
53 1
64 2
76 1
90 1
106 1
126 2
147 1
171 1
198 1

result:

ok 64 numbers

Test #76:

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

input:

32
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

output:

0 32
0 496
0 4960
0 35960
0 201376
0 906192
0 3365856
0 10518300
0 28048800
0 64512240
0 129024480
0 225792840
0 347373600
0 471435600
0 565722720
0 601080390
0 565722720
0 471435600
0 347373600
0 225792840
0 129024480
0 64512240
0 28048800
0 10518300
0 3365856
0 906192
0 201376
0 35960
0 4960
0 496...

result:

ok 64 numbers

Test #77:

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

input:

32
32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

0 32
1 496
3 4960
6 35960
10 201376
15 906192
21 3365856
28 10518300
36 28048800
45 64512240
55 129024480
66 225792840
78 347373600
91 471435600
105 565722720
120 601080390
136 565722720
153 471435600
171 347373600
190 225792840
210 129024480
231 64512240
253 28048800
276 10518300
300 3365856
325 90...

result:

ok 64 numbers

Test #78:

score: 0
Accepted
time: 2835ms
memory: 112108kb

input:

32
1 5 7 11 9 3 13 26 15 17 32 19 21 28 30 23 24 6 14 27 2 10 18 31 22 4 12 29 20 8 25 16

output:

0 32
0 300
0 1337
0 3528
0 6284
0 8125
0 7858
0 5704
0 3070
0 1192
0 317
0 52
0 4
1 4
2 1
5 2
9 5
13 3
18 3
24 3
31 3
39 2
48 1
59 1
72 3
85 1
100 3
115 1
133 2
152 1
174 2
196 1

result:

ok 64 numbers

Test #79:

score: 0
Accepted
time: 1619ms
memory: 46764kb

input:

32
16 25 8 20 4 29 12 22 31 27 18 14 10 6 2 24 32 30 28 23 15 26 21 7 13 19 17 11 5 9 3 1

output:

0 32
0 188
0 359
0 270
0 69
1 180
2 137
3 30
5 43
7 11
10 10
13 1
17 1
22 3
27 1
34 1
42 1
51 1
61 3
71 2
82 2
94 1
108 1
124 1
141 3
158 1
178 1
199 1
222 1
248 1
277 1
308 1

result:

ok 64 numbers

Test #80:

score: 0
Accepted
time: 85ms
memory: 8280kb

input:

32
2 21 3 26 5 24 1 30 4 18 6 27 8 19 7 32 9 22 11 28 10 23 12 31 14 20 13 29 16 25 17 15

output:

0 32
0 307
0 1442
0 4066
0 7566
0 9642
0 8471
0 5056
0 1970
0 456
0 48
1 120
2 116
3 54
4 12
5 1
8 5
11 5
14 1
19 1
26 1
34 1
43 1
53 3
63 1
75 1
91 2
107 1
126 2
145 1
167 2
189 1

result:

ok 64 numbers

Test #81:

score: 0
Accepted
time: 89ms
memory: 7876kb

input:

32
30 14 31 7 32 15 29 3 27 13 24 5 25 11 28 1 23 12 22 4 26 8 21 16 2 20 9 19 6 17 10 18

output:

0 32
0 189
0 374
0 315
0 123
0 20
0 1
2 8
4 13
6 5
9 5
13 13
17 7
21 1
27 2
34 2
42 2
51 4
60 2
70 2
81 1
94 1
109 5
124 3
140 1
158 3
176 1
198 1
223 1
250 1
278 1
307 1

result:

ok 64 numbers

Test #82:

score: 0
Accepted
time: 2004ms
memory: 83064kb

input:

32
2 26 11 23 32 20 29 8 17 14 5 3 9 30 15 24 12 18 27 6 21 1 28 16 4 31 22 7 19 10 25 13

output:

0 32
0 245
0 778
0 1313
0 1283
0 729
0 225
0 29
1 51
2 25
3 3
5 1
8 6
11 4
15 19
19 16
23 3
28 2
34 1
41 1
51 1
63 3
75 1
90 2
106 2
123 5
140 5
157 1
177 1
200 1
224 1
251 1

result:

ok 64 numbers

Test #83:

score: 0
Accepted
time: 1600ms
memory: 61692kb

input:

32
5 19 25 9 31 21 13 17 7 23 27 1 29 15 3 11 8 4 10 18 22 28 2 26 20 30 32 24 12 16 6 14

output:

0 32
0 259
0 872
0 1581
0 1739
0 1196
0 502
0 118
0 12
1 10
2 2
5 20
7 1
10 1
14 5
18 5
22 1
28 2
35 2
43 2
52 1
63 4
74 1
87 1
101 1
115 1
131 2
147 1
166 1
187 1
211 1
237 1

result:

ok 64 numbers

Test #84:

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

input:

32
2 1 4 3 5 6 7 8 9 10 12 11 13 14 16 15 18 17 19 20 21 22 23 24 25 26 28 27 29 30 32 31

output:

0 32
0 489
0 4750
0 32936
0 173544
0 722260
0 2436200
0 6780510
0 15771920
0 30939694
0 51507348
0 73056956
0 88459840
0 91447284
0 80570888
0 60276169
0 38058768
0 20103025
0 8772302
0 3106740
0 870424
0 185648
0 28320
0 2752
0 128
1 448
2 672
3 560
4 280
5 84
6 14
7 1

result:

ok 64 numbers

Test #85:

score: -100
Time Limit Exceeded

input:

32
2 4 6 14 12 8 10 16 23 18 30 26 28 21 32 20 1 24 17 9 5 31 13 27 22 3 11 29 19 7 25 15

output:


result: