QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#548302#7605. Yet Another Mex Problemsix-floor-slip-liuRE 671ms414968kbC++204.6kb2024-09-05 16:58:022024-09-05 16:58:03

Judging History

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

  • [2024-09-05 16:58:03]
  • 评测
  • 测评结果:RE
  • 用时:671ms
  • 内存:414968kb
  • [2024-09-05 16:58:02]
  • 提交

answer

#include<bits/stdc++.h>
#define forup(i,s,e) for(int i=(s),E123123123=(e);i<=E123123123;++i)
#define fordown(i,s,e) for(int i=(s),E123123123=(e);i>=E123123123;--i)
#define mem(a,b) memset(a,b,sizeof(a))
#ifdef DEBUG
#define msg(args...) fprintf(stderr,args)
#else
#define msg(...) void();
#endif
using namespace std;
using i64=long long;
using i128=__int128;
using pii=pair<int,i64>;
#define fi first
#define se second
#define mkp make_pair
#define gc getchar()
int read(){
    int x=0,f=1;char c;
    while(!isdigit(c=gc)) if(c=='-') f=-1;
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=gc;}
    return x*f;
}
#undef gc
const int N=2e5+5,B=1000,T=200;
i64 inf=1e18;
int n,m,a[N];
i64 sum[N];
int L[T],R[T],blg[N];
deque<pii> conv[T];
i128 cross(pii a,pii b){
    return a.fi*b.se-a.se*b.fi;
}
pii operator -(const pii a,const pii b){
    return mkp(a.fi-b.fi,a.se-b.se);
}
bool slp(pii a,pii b,pii c){
    return cross(b-a,c-b)<=0;
}
bool slp(pii a,pii b,i64 k){
    return (b.se-a.se)<(i128)(b.fi-a.fi)*k;
}
i64 dp[N];
int bkt[T][N],mex[T];
bool tag[T];
i64 mxv[T][N];
void work(int pl,int pr,int ql,int qr,int b){
    if(ql>qr) return;
    if(pl==pr){
        forup(i,ql,qr){
            mxv[b][i]=-sum[pl]*i+dp[pl];
        }
        return;
    }
    int mid=(ql+qr)>>1,p=0;
    i64 val=-inf;
    forup(i,pl,pr){
        if(-sum[i]*mid+dp[i]>val){
            p=i;
            val=-sum[i]*mid+dp[i];
        }
    }
    mxv[b][mid]=val;
    work(pl,p,mid+1,qr,b);work(p,pr,ql,mid-1,b);
}
void getconv(int j){
    deque<pii> &q=conv[j];
    q.clear();
    int mm=mex[j+1];
    vector<pii> vv;
    fordown(k,R[j],L[j]){
        while(bkt[j+1][mm]) ++mm;
        pii nw;
        nw.fi=mm;nw.se=mm*sum[k]-dp[k];
        vv.push_back(nw);
        ++bkt[j+1][a[k]];
    }
    forup(k,L[j],R[j]){
        --bkt[j+1][a[k]];
    }
    sort(vv.begin(),vv.end(),[&](pii a,pii b){if(a.fi!=b.fi)return a.fi<b.fi;return a.se<b.se;});
    for(auto i:vv){
        if(q.size()&&i.fi==q.back().fi) continue;
        while(q.size()>2&&slp(q[q.size()-2],q[q.size()-1],i)) q.pop_back();
        q.push_back(i);
    }
}
int bb[N],tt[N],m0;
signed main(){
    n=read();m=read();
    forup(i,1,n){
        a[i]=read();
        sum[i]=sum[i-1]+a[i];
    }
    int t=n/B;
    forup(i,1,t){
        L[i]=R[i-1]+1;R[i]=i*B;
        forup(j,L[i],R[i]) blg[j]=i;
    }
    if(R[t]!=n){
        ++t;
        L[t]=R[t-1]+1;R[t]=n;
        forup(j,L[t],R[t]) blg[j]=t;
    }
    forup(i,1,n){
        ++tt[a[i]];
        while(tt[m0]) ++m0;
        dp[i]=0;
        if(i<=m){
            dp[i]=max(dp[i],m0*sum[i]);
        }
        forup(j,1,t) tag[j]=0;
        fordown(j,blg[i],1){
            ++bkt[j][a[i]];
            while(bkt[j][mex[j]]) ++mex[j],tag[j]=1;
        }
        bb[a[i]]=1;
        int mm=0;
        fordown(j,i-1,max(L[blg[i]],i-m)){
            while(bb[mm]) ++mm;
            dp[i]=max(dp[i],dp[j]+mm*(sum[i]-sum[j]));
            bb[a[j]]=1;
        }
        fordown(j,i,max(L[blg[i]],i-m)){
            bb[a[j]]=0;
        }
        fordown(j,blg[i]-1,1){
            if(mex[j]!=mex[j+1]&&(tag[j]||tag[j+1])){
                getconv(j);
            }
        }
        if(i-m>=1&&blg[i]!=blg[i-m]){
            fordown(j,blg[i]-1,blg[i-m]+1){
                if(mex[j]==mex[j+1]){
                    dp[i]=max(dp[i],mex[j]*sum[i]+mxv[j][mex[j]]);
                    // msg("[%d]A %d %d %d %lld|%lld\n",i,L[j],R[j],mex[j],mxv[j][mex[j]],mex[j]*sum[i]+mxv[j][mex[j]]);
                }else{
                    while(conv[j].size()>=2&&slp(conv[j][0],conv[j][1],sum[i])) conv[j].pop_front();
                    dp[i]=max(dp[i],conv[j].front().fi*sum[i]-conv[j].front().se);
                    // msg("[%d]B %d %d %d %lld|%lld\n",i,L[j],R[j],conv[j].front().fi,-conv[j].front().se,conv[j].front().fi*sum[i]-conv[j].front().se);
                }
            }
            int mm=mex[blg[i-m]+1],p=blg[i-m]+1;;
            fordown(j,R[blg[i-m]],i-m){
                while(bkt[p][mm]) ++mm;
                dp[i]=max(dp[i],dp[j]+mm*(sum[i]-sum[j]));
                ++bkt[p][a[j]];
            }
            fordown(j,R[blg[i-m]],i-m){
                --bkt[p][a[j]];
            }
        }
        if(i==R[blg[i]]){
            work(L[blg[i]],R[blg[i]],0,n,blg[i]);
            getconv(blg[i]);
            // forup(j,0,n){
            //     msg("%lld ",mxv[blg[i]][j]);
            // }
            // msg("|\n");
        }
            // msg("%lld ",dp[i]);
    }
    // msg("|\n");
    printf("%lld\n",dp[n]);
}
/*
10 4
1 2 0 9 3 10 7 0 9 8 

*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 14144kb

input:

5 3
3 4 0 0 3

output:

10

result:

ok 1 number(s): "10"

Test #2:

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

input:

8 4
0 1 2 0 3 1 4 1

output:

26

result:

ok 1 number(s): "26"

Test #3:

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

input:

10 5
0 2 0 1 2 1 0 2 2 1

output:

33

result:

ok 1 number(s): "33"

Test #4:

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

input:

20 10
3 1 3 2 3 3 0 1 3 0 2 3 3 3 3 1 3 0 0 3

output:

160

result:

ok 1 number(s): "160"

Test #5:

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

input:

30 10
14 15 10 1 14 1 8 0 12 8 6 15 1 8 9 12 15 10 11 12 7 10 10 3 3 10 8 14 13 13

output:

172

result:

ok 1 number(s): "172"

Test #6:

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

input:

40 3
0 4 2 4 3 1 5 5 2 3 4 2 1 1 1 5 5 4 1 3 3 0 1 0 2 0 1 4 2 1 5 3 0 4 0 0 0 5 3 3

output:

51

result:

ok 1 number(s): "51"

Test #7:

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

input:

50 20
29 6 30 26 8 11 22 26 24 8 30 25 19 12 28 19 28 4 13 9 2 23 30 15 21 5 30 5 19 17 25 29 2 28 20 16 0 4 26 23 22 30 3 25 29 5 29 24 11 27

output:

378

result:

ok 1 number(s): "378"

Test #8:

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

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #9:

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

input:

100 30
41 50 33 22 1 34 7 14 31 44 46 49 49 23 33 12 9 41 25 23 22 1 49 45 45 8 10 49 37 23 48 17 32 44 38 21 29 27 23 27 47 44 6 12 7 2 18 12 9 43 20 26 26 8 14 25 18 48 2 41 49 7 48 38 10 45 34 27 17 12 1 19 9 29 50 13 25 21 9 13 26 15 6 9 5 13 47 30 26 17 40 0 21 6 25 24 22 31 43 16

output:

1308

result:

ok 1 number(s): "1308"

Test #10:

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

input:

200 30
1 26 8 2 6 36 43 49 15 48 39 7 12 18 28 46 13 6 24 17 43 44 31 17 30 5 40 19 13 24 26 1 23 39 34 29 28 2 22 23 32 21 32 5 38 11 18 10 15 14 16 7 40 40 35 30 8 3 46 25 36 50 13 37 16 42 39 9 24 5 8 2 15 17 24 35 39 26 5 24 39 23 47 17 23 49 21 30 36 46 26 15 0 24 23 25 12 16 12 18 42 30 20 0 5...

output:

3389

result:

ok 1 number(s): "3389"

Test #11:

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

input:

300 30
39 28 33 6 10 36 27 31 1 1 9 41 27 39 48 30 43 49 0 11 39 36 15 40 43 28 18 15 17 23 4 9 37 32 5 34 3 4 45 44 18 24 6 23 18 21 40 7 18 38 35 14 5 44 4 10 25 34 14 8 23 43 28 11 22 13 44 16 30 49 40 13 21 32 50 30 29 31 27 35 1 30 10 49 42 33 46 30 47 48 13 5 5 41 22 3 26 26 33 20 34 41 46 27 ...

output:

6636

result:

ok 1 number(s): "6636"

Test #12:

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

input:

400 30
25 30 7 36 38 37 10 15 37 6 4 49 42 34 43 13 46 40 1 6 35 29 50 13 30 23 48 12 43 23 32 44 28 28 1 41 2 31 44 40 5 1 6 17 50 5 40 5 48 36 32 47 20 24 25 42 17 40 8 43 9 10 43 34 30 36 48 48 37 18 21 23 26 20 24 2 44 10 22 46 38 12 50 4 9 17 19 30 6 25 1 20 33 33 21 6 15 11 27 22 2 25 22 30 8 ...

output:

5312

result:

ok 1 number(s): "5312"

Test #13:

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

input:

500 30
11 7 6 40 43 14 47 49 22 9 25 32 6 4 12 48 25 31 2 26 30 46 10 36 43 46 2 34 45 48 11 28 43 22 47 47 1 32 41 36 41 3 31 8 31 14 12 2 2 8 0 30 34 5 46 46 6 20 25 27 46 3 34 8 36 33 27 4 19 10 3 32 33 9 49 24 9 15 18 6 0 20 13 11 28 1 18 30 18 4 12 34 39 50 20 35 30 47 46 24 46 36 49 34 21 10 7...

output:

9118

result:

ok 1 number(s): "9118"

Test #14:

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

input:

600 30
49 8 31 19 46 14 31 32 33 39 20 15 46 25 6 32 2 48 28 20 26 39 44 9 5 43 31 30 23 47 39 10 33 42 44 3 26 7 15 6 28 31 5 2 11 24 11 1 6 6 21 10 25 36 16 26 23 27 19 10 33 47 49 7 43 5 32 37 24 3 9 17 39 49 24 20 50 20 15 18 12 27 3 43 46 36 43 31 28 32 50 50 44 43 19 13 20 6 15 26 14 45 25 11 ...

output:

9497

result:

ok 1 number(s): "9497"

Test #15:

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

input:

700 200
190 11 82 65 81 32 130 4 124 52 155 181 166 29 44 49 187 134 155 130 127 17 76 156 59 155 171 194 110 2 102 122 48 191 31 25 83 154 184 56 38 175 50 190 162 191 116 198 170 173 160 177 184 194 195 64 120 27 154 192 96 160 183 196 76 109 15 81 9 189 120 55 42 17 192 20 100 53 29 197 181 152 1...

output:

142372

result:

ok 1 number(s): "142372"

Test #16:

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

input:

800 200
197 112 65 12 115 42 97 158 105 122 140 175 154 63 192 103 43 87 11 114 164 35 179 101 171 13 104 179 185 78 96 75 93 19 191 108 136 161 152 183 123 199 99 197 147 185 82 112 6 157 178 180 200 47 95 15 153 71 89 172 182 98 187 19 129 126 59 166 2 75 135 86 64 37 58 64 148 195 45 165 125 115 ...

output:

193511

result:

ok 1 number(s): "193511"

Test #17:

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

input:

900 200
27 187 75 160 123 52 39 137 85 65 149 67 65 122 140 57 101 39 143 200 100 153 57 47 7 172 62 140 34 153 91 4 61 148 51 165 64 92 119 10 183 97 48 2 58 53 48 1 43 117 71 84 115 176 96 192 109 14 124 51 168 137 191 168 182 143 4 50 71 162 75 16 86 158 50 84 120 60 137 158 69 53 32 24 59 94 178...

output:

387825

result:

ok 1 number(s): "387825"

Test #18:

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

input:

1000 500
120 156 148 83 1 52 17 33 164 176 165 3 66 161 99 132 190 83 124 139 172 30 67 87 132 61 36 8 116 128 162 151 166 24 84 160 52 180 80 120 36 82 97 159 0 83 60 45 195 47 186 166 91 191 88 146 167 133 147 38 126 182 82 23 0 31 70 8 77 118 85 50 55 144 56 115 34 58 57 13 89 132 37 6 11 105 187...

output:

1033863

result:

ok 1 number(s): "1033863"

Test #19:

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

input:

2000 200
39 181 151 81 34 229 56 147 86 128 55 47 211 141 215 97 28 16 235 144 172 198 92 48 226 86 113 233 119 81 123 222 129 200 61 21 246 55 6 66 65 2 5 10 109 239 236 164 185 98 3 236 123 21 131 125 46 235 67 83 205 214 243 111 173 99 2 240 159 66 80 211 96 185 167 187 218 38 105 194 199 57 33 1...

output:

399183

result:

ok 1 number(s): "399183"

Test #20:

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

input:

3000 600
92 85 85 10 57 53 30 1 89 14 70 26 72 73 14 70 30 58 50 78 4 75 79 48 73 40 88 92 5 83 21 57 6 16 30 80 9 76 42 81 17 94 24 72 76 67 85 85 17 68 21 1 14 68 41 86 74 53 73 60 30 70 63 47 100 92 45 67 22 14 69 31 26 56 53 30 43 69 62 52 39 10 47 17 72 93 5 65 32 41 69 88 41 2 14 46 81 49 65 1...

output:

14762368

result:

ok 1 number(s): "14762368"

Test #21:

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

input:

4000 100
1073 699 498 1797 203 458 1112 1140 1749 1900 725 1926 579 396 1711 183 1673 300 1551 370 411 1926 1712 1191 411 54 1170 1324 551 860 68 1864 564 684 766 1300 1715 1849 303 1649 1375 1603 1885 605 403 687 1702 500 1801 1173 1842 443 125 405 1711 1951 1692 671 1983 1247 1451 1279 1075 1230 6...

output:

213208

result:

ok 1 number(s): "213208"

Test #22:

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

input:

5000 400
288 870 939 422 710 726 995 841 2 582 912 28 195 718 252 721 488 416 228 56 507 269 967 48 651 108 405 14 430 319 322 236 510 217 290 808 903 699 960 550 305 282 441 667 825 24 474 649 856 171 284 222 401 39 627 443 276 861 759 62 553 945 243 38 439 452 956 159 96 117 301 182 411 902 159 17...

output:

615424

result:

ok 1 number(s): "615424"

Test #23:

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

input:

6000 1000
226 126 99 274 50 247 244 91 70 104 263 208 196 299 211 268 69 76 278 72 80 11 120 172 224 239 53 296 198 20 282 184 9 96 133 214 79 15 201 220 64 282 211 225 250 256 122 9 1 180 280 44 16 62 90 208 102 140 173 70 242 136 235 249 6 23 38 62 135 204 82 227 281 167 96 233 196 97 243 105 117 ...

output:

45326920

result:

ok 1 number(s): "45326920"

Test #24:

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

input:

7000 3000
321 1652 403 108 1343 744 985 327 1395 1330 1752 1681 1246 1709 1726 1087 1982 1493 8 1798 1400 258 228 1486 589 212 227 421 805 1796 1101 1039 406 170 1128 1765 960 1503 563 346 1495 1477 1421 1367 861 1321 1739 1138 84 1001 1277 1026 977 2 54 812 754 572 1881 1229 30 1659 1566 950 1026 1...

output:

36659018

result:

ok 1 number(s): "36659018"

Test #25:

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

input:

8000 150
0 12 10 13 8 6 2 11 5 11 3 18 7 13 1 11 1 8 11 3 15 13 2 10 5 13 14 15 11 9 20 15 12 1 16 12 6 3 7 7 12 6 11 12 20 18 2 16 13 11 12 2 11 19 17 16 4 11 6 6 12 13 16 9 2 6 15 3 8 2 14 5 17 11 11 19 9 4 6 18 3 20 3 5 10 6 5 10 12 13 14 16 4 15 6 10 7 4 7 15 1 19 15 11 16 20 12 13 15 12 7 12 20...

output:

1669500

result:

ok 1 number(s): "1669500"

Test #26:

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

input:

9000 300
163 487 36 261 54 222 344 292 212 127 139 152 235 463 238 36 240 247 125 399 373 159 372 442 461 57 333 12 68 392 152 490 309 403 63 111 426 280 412 219 110 417 314 264 135 180 214 402 249 232 248 81 128 110 29 209 323 187 109 78 213 313 67 201 466 456 485 197 305 27 202 4 50 465 57 300 244...

output:

2644852

result:

ok 1 number(s): "2644852"

Test #27:

score: 0
Accepted
time: 17ms
memory: 28424kb

input:

10000 2500
60 9 63 25 100 71 100 80 47 69 33 6 40 61 4 14 44 74 21 63 0 46 62 74 81 69 45 16 56 57 50 4 34 24 42 49 0 12 12 77 38 40 58 46 87 67 28 24 9 28 93 86 11 44 17 7 24 100 5 86 3 34 55 36 23 20 22 84 73 79 30 100 45 42 14 39 82 13 93 14 95 23 87 11 85 95 67 49 46 73 40 94 96 51 10 90 60 18 1...

output:

50431320

result:

ok 1 number(s): "50431320"

Test #28:

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

input:

20000 13240
1671 652 803 323 143 1942 1718 189 757 1779 1151 1979 1862 475 104 854 945 1548 31 1271 1108 1605 539 852 1434 1030 140 99 909 466 1508 66 366 67 766 1576 1550 771 1387 1745 1576 1246 355 1426 206 1673 1743 1922 987 156 195 654 1309 1982 1757 192 857 1337 59 58 300 1150 1306 1605 1549 17...

output:

22824367976

result:

ok 1 number(s): "22824367976"

Test #29:

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

input:

30000 15
4488 8417 5442 13552 1710 1057 2687 6544 8403 184 6159 8748 970 3404 16081 15317 2110 14976 3702 17437 16036 8210 11615 9772 13720 15049 787 12867 10344 347 15109 16579 16688 2184 6793 9358 13252 1302 18701 17410 596 2975 5151 4811 3325 9989 15191 19731 16512 8808 6841 5778 5829 12444 2546 ...

output:

478518

result:

ok 1 number(s): "478518"

Test #30:

score: 0
Accepted
time: 80ms
memory: 75752kb

input:

40000 2300
134 76 295 71 92 165 74 221 277 147 176 294 156 38 255 81 48 122 149 294 136 194 236 147 27 99 94 0 9 202 118 194 120 241 139 267 107 261 122 222 240 201 152 121 240 285 111 162 29 10 112 220 245 126 105 31 152 192 236 31 103 16 149 58 29 26 156 113 286 120 237 164 235 243 282 98 112 114 ...

output:

1813249585

result:

ok 1 number(s): "1813249585"

Test #31:

score: 0
Accepted
time: 54ms
memory: 92424kb

input:

50000 47200
48 51 12 58 40 77 65 53 9 53 25 57 96 35 96 6 62 20 24 96 28 89 4 95 60 23 48 48 99 29 70 27 21 79 28 83 16 27 48 41 31 35 52 64 7 93 18 42 62 62 20 2 15 47 23 26 89 68 56 81 84 74 15 32 63 39 91 36 31 31 55 39 66 55 82 88 77 19 12 31 84 3 0 76 74 57 50 79 25 7 66 18 18 25 43 10 3 3 73 5...

output:

252581810

result:

ok 1 number(s): "252581810"

Test #32:

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

input:

60000 120
11 6 1 8 12 2 10 8 12 16 3 4 13 3 16 10 6 2 0 0 4 7 9 20 14 19 14 11 15 7 0 10 0 19 2 1 13 12 9 6 3 4 16 11 12 0 8 10 4 6 3 12 5 20 8 4 9 20 18 10 5 17 0 19 8 7 1 15 11 16 18 13 10 17 6 16 6 9 20 8 10 3 11 14 15 2 15 7 16 19 0 6 8 15 14 9 19 19 20 15 13 13 20 14 0 4 17 19 12 6 9 11 18 17 2...

output:

12541179

result:

ok 1 number(s): "12541179"

Test #33:

score: 0
Accepted
time: 179ms
memory: 132920kb

input:

70000 2220
2956 17775 3950 11853 6101 4568 18097 544 3682 18293 15021 16222 3925 3088 3026 8886 13593 12895 3359 11967 12619 16775 7860 16450 17435 17273 14932 19110 14349 18846 18676 13824 8847 10272 4733 13886 7350 10214 12502 7168 10567 1678 4531 19885 7346 4727 16945 10475 16567 4100 10668 6451 ...

output:

45791760

result:

ok 1 number(s): "45791760"

Test #34:

score: 0
Accepted
time: 134ms
memory: 145272kb

input:

80000 39300
6715 4713 10051 1521 5710 2979 11372 3283 4612 7347 690 4818 10115 2487 4965 9954 5465 2948 4511 2920 10075 1895 8640 6727 6651 1158 2093 4658 6375 5108 4190 4757 1221 10995 8481 9219 2435 8250 5706 10070 9212 8977 7594 1993 241 8122 6388 10849 11251 8698 4617 6368 9661 1987 9564 10004 2...

output:

18375296469

result:

ok 1 number(s): "18375296469"

Test #35:

score: 0
Accepted
time: 232ms
memory: 167572kb

input:

90000 1300
15007 16458 10113 20044 18328 4720 4604 11365 17509 9179 1317 18034 20216 518 5697 9688 16268 9811 14165 9135 2667 2527 14719 4650 14650 16940 9228 3146 8515 14594 1018 1869 20094 12799 3780 3455 15991 18139 18978 15467 14362 16280 10388 9706 1470 13198 9682 1754 16431 10615 859 4689 5833...

output:

54307220

result:

ok 1 number(s): "54307220"

Test #36:

score: 0
Accepted
time: 184ms
memory: 170496kb

input:

100000 25000
540 639 345 500 602 194 221 111 651 108 704 619 807 290 635 680 366 255 557 123 227 42 461 673 559 245 179 436 318 727 717 355 81 188 826 12 675 628 748 562 568 72 671 122 609 594 161 527 9 863 473 831 264 155 302 73 297 67 818 319 264 737 343 855 59 161 38 373 848 578 278 414 316 497 2...

output:

40721014855

result:

ok 1 number(s): "40721014855"

Test #37:

score: 0
Accepted
time: 199ms
memory: 186608kb

input:

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

output:

6056292

result:

ok 1 number(s): "6056292"

Test #38:

score: 0
Accepted
time: 359ms
memory: 238000kb

input:

120000 3000
35666 7882 37712 12815 34337 21246 13751 23696 23460 12356 14168 3857 732 34967 5702 2443 40204 36249 37996 8860 38143 2105 22898 21684 29154 43216 30314 23114 22409 13492 27367 2551 16566 16158 20581 994 39648 30803 10209 40564 37189 23285 23053 12086 6276 28475 19199 20490 28122 10228 ...

output:

195335523

result:

ok 1 number(s): "195335523"

Test #39:

score: 0
Accepted
time: 281ms
memory: 224712kb

input:

130000 10000
5259 4702 1126 5176 3179 5610 4249 4599 6216 3591 6385 238 1116 6374 3839 3053 5124 5273 4088 463 88 4544 4203 495 3760 5596 2369 3945 5260 2234 5085 2814 5785 1898 3184 5977 4788 464 1529 3636 4361 644 3674 5319 3263 2820 2382 1909 4304 4614 5541 2303 3877 27 399 6173 5121 2454 6070 11...

output:

2197792965

result:

ok 1 number(s): "2197792965"

Test #40:

score: 0
Accepted
time: 237ms
memory: 244932kb

input:

140000 100000
1867 10443 4397 7524 481 6233 1102 9500 748 8163 5667 1361 8486 2664 11080 10373 10365 4509 1688 2254 6865 11163 7796 1032 11083 1618 11012 7286 10940 1402 2407 2296 3738 2498 7938 8769 8830 11687 7243 5353 8228 4848 10768 9489 5315 7701 3105 4599 231 5417 2355 8485 174 4224 4045 12178...

output:

6359230739832

result:

ok 1 number(s): "6359230739832"

Test #41:

score: 0
Accepted
time: 513ms
memory: 346024kb

input:

150000 20000
14421 92873 90302 90166 8947 58218 12506 3618 106562 276 23156 6233 7641 10849 20639 50333 38367 90365 11891 110299 111850 73741 107109 1406 12035 64725 95507 34747 17540 58198 22728 56070 83619 72857 99120 40053 112490 15238 103801 38199 83708 74699 65613 50979 56109 104708 109030 1334...

output:

1135213498

result:

ok 1 number(s): "1135213498"

Test #42:

score: 0
Accepted
time: 67ms
memory: 267128kb

input:

160000 20
143 51 50 107 124 53 126 115 22 49 101 136 106 72 89 78 54 49 80 129 131 121 117 139 89 108 93 28 68 67 26 98 66 57 74 88 80 2 79 122 89 27 113 145 16 13 37 128 149 104 63 135 95 94 130 16 126 48 70 131 106 72 124 40 133 121 10 51 147 139 80 81 89 146 0 128 140 65 29 90 146 5 118 106 8 64 ...

output:

1948715

result:

ok 1 number(s): "1948715"

Test #43:

score: 0
Accepted
time: 389ms
memory: 284472kb

input:

170000 3000
613 1590 3797 2686 992 297 4336 1824 4018 2580 189 1361 4240 2372 935 4298 4149 167 3333 570 184 3319 2432 4037 2673 650 430 2111 3637 534 130 1649 189 959 1792 2155 478 4131 2804 3926 1267 2122 2740 4347 2234 1138 1967 2978 848 4334 3183 2066 2887 3887 2643 1704 2919 1138 660 1224 943 4...

output:

630425250

result:

ok 1 number(s): "630425250"

Test #44:

score: 0
Accepted
time: 276ms
memory: 317688kb

input:

180000 179000
13624 7501 2849 10406 13592 161 11019 13678 7809 3937 14047 10644 9569 14135 12608 8618 10932 5979 5637 14248 8232 2643 7659 2214 11458 7961 8216 11913 9719 12243 15098 4347 701 1019 14444 7362 4697 15897 1766 15865 16026 15278 15892 12768 772 14470 10994 3730 197 12940 2162 20 13286 7...

output:

23037229707541

result:

ok 1 number(s): "23037229707541"

Test #45:

score: 0
Accepted
time: 260ms
memory: 307380kb

input:

180000 160000
3374 1675 706 4305 8017 6777 6208 1901 815 6746 3278 6813 7583 2686 7734 1801 6849 6023 6983 7170 6763 276 1852 5490 1429 3900 2995 2833 6168 6093 3658 3537 3734 5540 3113 6947 5364 1023 726 1499 6056 1077 3196 8016 980 5163 6282 2410 7036 3776 4670 1100 6515 1013 7664 892 2335 7756 17...

output:

6065208427973

result:

ok 1 number(s): "6065208427973"

Test #46:

score: 0
Accepted
time: 671ms
memory: 414968kb

input:

190000 20000
38719 46306 49633 36758 28671 33007 10434 51874 33262 9800 25149 38985 53274 76666 27594 46467 33301 67035 35981 41063 16339 45790 78132 14148 78444 45659 2322 31870 17500 24647 1071 60217 35241 52480 7705 14743 21110 44251 68474 1079 40794 43902 5018 7811 47853 64074 18840 23557 44160 ...

output:

5174768275

result:

ok 1 number(s): "5174768275"

Test #47:

score: -100
Runtime Error

input:

200000 30000
2999 5198 1375 5255 6485 1392 3671 3274 6894 7578 1250 4359 9834 3972 9411 7450 8105 5637 8216 6163 6446 6615 6463 5546 5979 116 5625 6452 3026 3774 5787 1416 1094 4828 2107 8545 1009 5553 4329 4838 4612 5522 7845 9475 2231 4442 7700 1592 9001 2835 7980 5637 8975 7689 5495 1127 8502 584...

output:


result: