QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767529#8268. Tycho_8_8_100 ✓89ms16524kbC++202.3kb2024-11-20 21:11:562024-11-20 21:11:57

Judging History

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

  • [2024-11-20 21:11:57]
  • 评测
  • 测评结果:100
  • 用时:89ms
  • 内存:16524kb
  • [2024-11-20 21:11:56]
  • 提交

answer

#include <bits/stdc++.h> 

using namespace std;

typedef long long ll;

const int N = (int)1e6 + 12;

const ll inf = 11e17;

ll b, p, d, n, a[N], m;
ll dp[N];
vector<ll> c;
struct segtree{
    vector<ll> t;
    void init() {
        t.assign(m * 4, inf);
    }
    void upd(int pos, ll val, int v = 1, int tl = 0, int tr = m - 1) {
        if(tl == tr) {
            t[v] = min(t[v], val);
        } else {
            int tm = (tl + tr) >> 1;
            if(pos <= tm) upd(pos, val, v + v, tl, tm);
            else upd(pos, val, v + v + 1, tm + 1, tr);
            t[v] = min(t[v + v], t[v + v + 1]);
        }
    }
    ll get(int l, int r, int v = 1, int tl = 0, int tr = m - 1) {
        if(l > r || tl > r || l > tr) return inf;
        if(tl >= l && tr <= r) return t[v];
        int tm = (tl + tr) >> 1;
        return min(get(l, r, v + v, tl, tm), get(l, r, v + v + 1, tm + 1, tr));
    }
}pr, sf;

void upd_pr(ll i) {
    int it = lower_bound(c.begin(), c.end(), a[i] % p) - c.begin();
    pr.upd(it, dp[i] - (a[i] / p) * d + a[i] % p);
}
void upd_sf(ll i) {
    int it = lower_bound(c.begin(), c.end(), a[i] % p) - c.begin();
    sf.upd(it, dp[i] + a[i] % p - (a[i] / p) * d);
}
ll get_pr(ll i) {
    int it = lower_bound(c.begin(), c.end(), a[i] % p) - c.begin();
    return pr.get(0, it - 1) + (a[i] / p) * d + p - (a[i] % p);
}
ll get_sf(ll i) {
    int it = lower_bound(c.begin(), c.end(), a[i] % p) - c.begin();
    return sf.get(it, m - 1) + (a[i] / p) * d - d - (a[i] % p);
}
void test() {
    cin >> b >> p >> d >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        c.push_back(a[i] % p);
    }
    c.push_back(0);
    sort(c.begin(), c.end());
    c.resize(unique(c.begin(), c.end()) - c.begin());
    m = (int)c.size();
    pr.init();
    sf.init();
    upd_pr(0);
    upd_sf(0);
    for(int i = 1; i <= n; i++) {
        dp[i] = min(get_pr(i), get_sf(i));
        upd_pr(i);
        upd_sf(i);
    }
    ll res = inf;
    for(int i = 0; i <= n; i++) {
        ll r = b - a[i] - 1;
        res = min(res, dp[i] + (r / p)  * d);
    }
    cout << res + b << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    // cin >> t;

    while(t--) 
        test();

    return 0;
}

詳細信息

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 1ms
memory: 5604kb

input:

1000000000000 1 1000000 0

output:

1000000999999000000

result:

ok single line: '1000000999999000000'

Test #2:

score: 8
Accepted
time: 1ms
memory: 5660kb

input:

100 10 11 10
10
11
20
30
38
49
50
60
70
90

output:

122

result:

ok single line: '122'

Test #3:

score: 8
Accepted
time: 1ms
memory: 5664kb

input:

100 10 11 15
1
5
9
15
24
25
39
40
45
66
75
79
85
95
97

output:

138

result:

ok single line: '138'

Test #4:

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

input:

100000 1000 123 1000
20
25
139
161
312
336
379
472
780
803
1000
1117
1132
1159
1411
1429
1430
1623
1964
2000
2266
2284
2537
2717
2963
3000
3153
3217
3400
3462
3477
3525
3542
3711
3754
3946
3958
4000
4091
4102
4131
4458
4649
4661
4804
4883
4898
4913
4979
5000
5210
5243
5357
5383
5393
5441
5627
5969
6...

output:

100984

result:

ok single line: '100984'

Test #5:

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

input:

100000 100 123 1000
409
858
938
958
1058
1125
1148
1158
1175
1258
1307
1310
1358
1458
1597
1658
1743
1758
1858
2058
2092
2258
2343
2358
2444
2458
2558
2658
2690
2758
2806
2845
2958
3058
3091
3151
3258
3358
3474
3558
3658
3758
3992
4158
4258
4358
4458
4718
5039
5058
5227
5458
5758
5797
5858
5928
5958...

output:

153301

result:

ok single line: '153301'

Test #6:

score: 8
Accepted
time: 11ms
memory: 10300kb

input:

1000000000000 1000000 12345 100000
14000000
22000000
24000000
32000000
44000000
56000000
74000000
87000000
98000000
106000000
126000000
132000000
146000000
171000000
174000000
177000000
195000000
208000000
223000000
224000000
230000000
232000000
246000000
257000000
279000000
282000000
283000000
3200...

output:

1011111722155

result:

ok single line: '1011111722155'

Test #7:

score: 8
Accepted
time: 33ms
memory: 9392kb

input:

1000000000000 1000000 12345 100000
95
241
461
643
755
955
957
1000
1003
1154
1414
1555
1584
1626
1951
2018
2105
2121
2249
2253
2281
2405
2438
2472
2562
2815
2863
2892
2972
3070
3298
3352
3414
3537
3581
3664
3717
4092
4096
4101
4324
4572
4645
4758
4874
4905
4927
4981
5238
5372
5426
5545
5733
5778
604...

output:

1011233973415

result:

ok single line: '1011233973415'

Test #8:

score: 8
Accepted
time: 1ms
memory: 5600kb

input:

18 4 0 2
8
15

output:

18

result:

ok single line: '18'

Test #9:

score: 8
Accepted
time: 1ms
memory: 5604kb

input:

18 10 100 2
8
15

output:

20

result:

ok single line: '20'

Test #10:

score: 8
Accepted
time: 1ms
memory: 5664kb

input:

18 4 100 0

output:

418

result:

ok single line: '418'

Subtask #2:

score: 5
Accepted

Test #11:

score: 5
Accepted
time: 1ms
memory: 5604kb

input:

108 100 10000 5
10
20
30
40
98

output:

110

result:

ok single line: '110'

Test #12:

score: 5
Accepted
time: 1ms
memory: 5596kb

input:

118 100 10000 5
10
20
30
98
108

output:

120

result:

ok single line: '120'

Test #13:

score: 5
Accepted
time: 1ms
memory: 5664kb

input:

206 100 10000 5
10
20
30
98
196

output:

210

result:

ok single line: '210'

Test #14:

score: 5
Accepted
time: 1ms
memory: 5600kb

input:

128 100 10000 5
10
20
98
108
118

output:

130

result:

ok single line: '130'

Test #15:

score: 5
Accepted
time: 1ms
memory: 5592kb

input:

206 100 10000 5
10
20
98
108
196

output:

210

result:

ok single line: '210'

Test #16:

score: 5
Accepted
time: 1ms
memory: 5664kb

input:

216 100 10000 5
10
20
98
196
206

output:

220

result:

ok single line: '220'

Test #17:

score: 5
Accepted
time: 1ms
memory: 5592kb

input:

304 100 10000 5
10
20
98
196
294

output:

310

result:

ok single line: '310'

Test #18:

score: 5
Accepted
time: 1ms
memory: 5660kb

input:

138 100 10000 5
10
98
108
118
128

output:

140

result:

ok single line: '140'

Test #19:

score: 5
Accepted
time: 1ms
memory: 5600kb

input:

206 100 10000 5
10
98
108
118
196

output:

210

result:

ok single line: '210'

Test #20:

score: 5
Accepted
time: 1ms
memory: 5664kb

input:

216 100 10000 5
10
98
108
196
206

output:

220

result:

ok single line: '220'

Test #21:

score: 5
Accepted
time: 1ms
memory: 5668kb

input:

304 100 10000 5
10
98
108
196
294

output:

310

result:

ok single line: '310'

Test #22:

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

input:

226 100 10000 5
10
98
196
206
216

output:

230

result:

ok single line: '230'

Test #23:

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

input:

304 100 10000 5
10
98
196
206
294

output:

310

result:

ok single line: '310'

Test #24:

score: 5
Accepted
time: 1ms
memory: 5664kb

input:

314 100 10000 5
10
98
196
294
304

output:

320

result:

ok single line: '320'

Test #25:

score: 5
Accepted
time: 1ms
memory: 5668kb

input:

402 100 10000 5
10
98
196
294
392

output:

410

result:

ok single line: '410'

Test #26:

score: 5
Accepted
time: 1ms
memory: 5680kb

input:

148 100 10000 5
98
108
118
128
138

output:

150

result:

ok single line: '150'

Test #27:

score: 5
Accepted
time: 1ms
memory: 5672kb

input:

206 100 10000 5
98
108
118
128
196

output:

210

result:

ok single line: '210'

Test #28:

score: 5
Accepted
time: 1ms
memory: 5680kb

input:

216 100 10000 5
98
108
118
196
206

output:

220

result:

ok single line: '220'

Test #29:

score: 5
Accepted
time: 1ms
memory: 5668kb

input:

304 100 10000 5
98
108
118
196
294

output:

310

result:

ok single line: '310'

Test #30:

score: 5
Accepted
time: 1ms
memory: 5604kb

input:

226 100 10000 5
98
108
196
206
216

output:

230

result:

ok single line: '230'

Test #31:

score: 5
Accepted
time: 1ms
memory: 5596kb

input:

304 100 10000 5
98
108
196
206
294

output:

310

result:

ok single line: '310'

Test #32:

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

input:

314 100 10000 5
98
108
196
294
304

output:

320

result:

ok single line: '320'

Test #33:

score: 5
Accepted
time: 1ms
memory: 5736kb

input:

402 100 10000 5
98
108
196
294
392

output:

410

result:

ok single line: '410'

Test #34:

score: 5
Accepted
time: 1ms
memory: 5664kb

input:

236 100 10000 5
98
196
206
216
226

output:

240

result:

ok single line: '240'

Test #35:

score: 5
Accepted
time: 1ms
memory: 5600kb

input:

304 100 10000 5
98
196
206
216
294

output:

310

result:

ok single line: '310'

Test #36:

score: 5
Accepted
time: 1ms
memory: 5728kb

input:

314 100 10000 5
98
196
206
294
304

output:

320

result:

ok single line: '320'

Test #37:

score: 5
Accepted
time: 1ms
memory: 5604kb

input:

402 100 10000 5
98
196
206
294
392

output:

410

result:

ok single line: '410'

Test #38:

score: 5
Accepted
time: 1ms
memory: 5592kb

input:

324 100 10000 5
98
196
294
304
314

output:

330

result:

ok single line: '330'

Test #39:

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

input:

402 100 10000 5
98
196
294
304
392

output:

410

result:

ok single line: '410'

Test #40:

score: 5
Accepted
time: 1ms
memory: 5596kb

input:

412 100 10000 5
98
196
294
392
402

output:

420

result:

ok single line: '420'

Test #41:

score: 5
Accepted
time: 1ms
memory: 5728kb

input:

500 100 10000 5
98
196
294
392
490

output:

510

result:

ok single line: '510'

Test #42:

score: 5
Accepted
time: 1ms
memory: 5600kb

input:

10 2 10 2
1
3

output:

41

result:

ok single line: '41'

Test #43:

score: 5
Accepted
time: 1ms
memory: 5728kb

input:

100 21 10 2
5
54

output:

140

result:

ok single line: '140'

Test #44:

score: 5
Accepted
time: 1ms
memory: 5664kb

input:

100 21 10 9
18
21
53
62
85
86
88
90
91

output:

121

result:

ok single line: '121'

Test #45:

score: 5
Accepted
time: 1ms
memory: 5604kb

input:

100 21 10 10
30
39
40
43
45
49
52
57
70
72

output:

132

result:

ok single line: '132'

Test #46:

score: 5
Accepted
time: 1ms
memory: 5680kb

input:

156 20 1 10
19
37
54
70
85
99
112
124
135
145

output:

162

result:

ok single line: '162'

Test #47:

score: 5
Accepted
time: 1ms
memory: 5660kb

input:

156 20 20 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #48:

score: 5
Accepted
time: 1ms
memory: 5668kb

input:

156 20 30 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #49:

score: 5
Accepted
time: 1ms
memory: 5572kb

input:

18 4 5 2
8
15

output:

29

result:

ok single line: '29'

Test #50:

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

input:

18 4 0 2
8
15

output:

18

result:

ok single line: '18'

Test #51:

score: 5
Accepted
time: 1ms
memory: 5660kb

input:

18 10 100 2
8
15

output:

20

result:

ok single line: '20'

Test #52:

score: 5
Accepted
time: 1ms
memory: 5632kb

input:

18 4 100 0

output:

418

result:

ok single line: '418'

Test #53:

score: 5
Accepted
time: 1ms
memory: 5664kb

input:

65 20 100 3
14
25
33

output:

172

result:

ok single line: '172'

Subtask #3:

score: 7
Accepted

Dependency #2:

100%
Accepted

Test #54:

score: 7
Accepted
time: 1ms
memory: 5656kb

input:

108 100 10000 5
10
20
30
40
98

output:

110

result:

ok single line: '110'

Test #55:

score: 7
Accepted
time: 1ms
memory: 5732kb

input:

118 100 10000 5
10
20
30
98
108

output:

120

result:

ok single line: '120'

Test #56:

score: 7
Accepted
time: 1ms
memory: 5732kb

input:

206 100 10000 5
10
20
30
98
196

output:

210

result:

ok single line: '210'

Test #57:

score: 7
Accepted
time: 1ms
memory: 5600kb

input:

128 100 10000 5
10
20
98
108
118

output:

130

result:

ok single line: '130'

Test #58:

score: 7
Accepted
time: 1ms
memory: 5600kb

input:

206 100 10000 5
10
20
98
108
196

output:

210

result:

ok single line: '210'

Test #59:

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

input:

216 100 10000 5
10
20
98
196
206

output:

220

result:

ok single line: '220'

Test #60:

score: 7
Accepted
time: 1ms
memory: 5600kb

input:

304 100 10000 5
10
20
98
196
294

output:

310

result:

ok single line: '310'

Test #61:

score: 7
Accepted
time: 1ms
memory: 5644kb

input:

138 100 10000 5
10
98
108
118
128

output:

140

result:

ok single line: '140'

Test #62:

score: 7
Accepted
time: 1ms
memory: 5664kb

input:

206 100 10000 5
10
98
108
118
196

output:

210

result:

ok single line: '210'

Test #63:

score: 7
Accepted
time: 1ms
memory: 5668kb

input:

216 100 10000 5
10
98
108
196
206

output:

220

result:

ok single line: '220'

Test #64:

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

input:

304 100 10000 5
10
98
108
196
294

output:

310

result:

ok single line: '310'

Test #65:

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

input:

226 100 10000 5
10
98
196
206
216

output:

230

result:

ok single line: '230'

Test #66:

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

input:

304 100 10000 5
10
98
196
206
294

output:

310

result:

ok single line: '310'

Test #67:

score: 7
Accepted
time: 1ms
memory: 5660kb

input:

314 100 10000 5
10
98
196
294
304

output:

320

result:

ok single line: '320'

Test #68:

score: 7
Accepted
time: 1ms
memory: 5560kb

input:

402 100 10000 5
10
98
196
294
392

output:

410

result:

ok single line: '410'

Test #69:

score: 7
Accepted
time: 1ms
memory: 5592kb

input:

148 100 10000 5
98
108
118
128
138

output:

150

result:

ok single line: '150'

Test #70:

score: 7
Accepted
time: 1ms
memory: 5608kb

input:

206 100 10000 5
98
108
118
128
196

output:

210

result:

ok single line: '210'

Test #71:

score: 7
Accepted
time: 1ms
memory: 5668kb

input:

216 100 10000 5
98
108
118
196
206

output:

220

result:

ok single line: '220'

Test #72:

score: 7
Accepted
time: 1ms
memory: 5664kb

input:

304 100 10000 5
98
108
118
196
294

output:

310

result:

ok single line: '310'

Test #73:

score: 7
Accepted
time: 1ms
memory: 5720kb

input:

226 100 10000 5
98
108
196
206
216

output:

230

result:

ok single line: '230'

Test #74:

score: 7
Accepted
time: 1ms
memory: 5724kb

input:

304 100 10000 5
98
108
196
206
294

output:

310

result:

ok single line: '310'

Test #75:

score: 7
Accepted
time: 1ms
memory: 5636kb

input:

314 100 10000 5
98
108
196
294
304

output:

320

result:

ok single line: '320'

Test #76:

score: 7
Accepted
time: 1ms
memory: 5604kb

input:

402 100 10000 5
98
108
196
294
392

output:

410

result:

ok single line: '410'

Test #77:

score: 7
Accepted
time: 1ms
memory: 5724kb

input:

236 100 10000 5
98
196
206
216
226

output:

240

result:

ok single line: '240'

Test #78:

score: 7
Accepted
time: 1ms
memory: 5664kb

input:

304 100 10000 5
98
196
206
216
294

output:

310

result:

ok single line: '310'

Test #79:

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

input:

314 100 10000 5
98
196
206
294
304

output:

320

result:

ok single line: '320'

Test #80:

score: 7
Accepted
time: 1ms
memory: 5668kb

input:

402 100 10000 5
98
196
206
294
392

output:

410

result:

ok single line: '410'

Test #81:

score: 7
Accepted
time: 1ms
memory: 5668kb

input:

324 100 10000 5
98
196
294
304
314

output:

330

result:

ok single line: '330'

Test #82:

score: 7
Accepted
time: 1ms
memory: 5660kb

input:

402 100 10000 5
98
196
294
304
392

output:

410

result:

ok single line: '410'

Test #83:

score: 7
Accepted
time: 1ms
memory: 5656kb

input:

412 100 10000 5
98
196
294
392
402

output:

420

result:

ok single line: '420'

Test #84:

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

input:

500 100 10000 5
98
196
294
392
490

output:

510

result:

ok single line: '510'

Test #85:

score: 7
Accepted
time: 1ms
memory: 5724kb

input:

10 2 10 2
1
3

output:

41

result:

ok single line: '41'

Test #86:

score: 7
Accepted
time: 1ms
memory: 5676kb

input:

100 21 10 2
5
54

output:

140

result:

ok single line: '140'

Test #87:

score: 7
Accepted
time: 1ms
memory: 5664kb

input:

100 21 10 9
18
21
53
62
85
86
88
90
91

output:

121

result:

ok single line: '121'

Test #88:

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

input:

100 21 10 10
30
39
40
43
45
49
52
57
70
72

output:

132

result:

ok single line: '132'

Test #89:

score: 7
Accepted
time: 1ms
memory: 5680kb

input:

156 20 1 10
19
37
54
70
85
99
112
124
135
145

output:

162

result:

ok single line: '162'

Test #90:

score: 7
Accepted
time: 1ms
memory: 5640kb

input:

156 20 20 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #91:

score: 7
Accepted
time: 1ms
memory: 5628kb

input:

156 20 30 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #92:

score: 7
Accepted
time: 1ms
memory: 5632kb

input:

10 2 10 0

output:

50

result:

ok single line: '50'

Test #93:

score: 7
Accepted
time: 1ms
memory: 5732kb

input:

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

output:

10

result:

ok single line: '10'

Test #94:

score: 7
Accepted
time: 1ms
memory: 5660kb

input:

10 2 10 3
2
4
6

output:

20

result:

ok single line: '20'

Test #95:

score: 7
Accepted
time: 1ms
memory: 5600kb

input:

100 2 10 33
2
5
6
9
10
12
18
26
29
30
32
34
35
42
49
50
52
53
55
56
58
61
62
63
69
71
73
74
82
89
91
93
94

output:

356

result:

ok single line: '356'

Test #96:

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

input:

100 2 10 50
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

output:

340

result:

ok single line: '340'

Test #97:

score: 7
Accepted
time: 1ms
memory: 5616kb

input:

100 2 10 50
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

output:

340

result:

ok single line: '340'

Test #98:

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

input:

100 2 10 50
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
61
63
65
67
69
71
73
75
77
79
81
83
85
87
89
91
93
95
97
99

output:

101

result:

ok single line: '101'

Test #99:

score: 7
Accepted
time: 1ms
memory: 5636kb

input:

1000 2 10 999
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:

1000

result:

ok single line: '1000'

Test #100:

score: 7
Accepted
time: 1ms
memory: 5604kb

input:

1000 42 15 100
9
10
31
35
39
42
53
68
75
77
78
92
117
121
123
141
146
147
157
166
167
193
221
222
231
247
255
265
275
292
305
313
341
343
344
352
357
364
371
380
388
392
410
417
418
445
450
451
452
460
476
479
485
498
501
505
515
524
532
539
542
565
569
570
580
581
585
593
607
618
633
634
642
661
66...

output:

1126

result:

ok single line: '1126'

Test #101:

score: 7
Accepted
time: 1ms
memory: 5604kb

input:

1000 42 14 100
8
15
24
35
46
60
71
98
102
113
125
126
159
164
181
183
191
199
208
212
216
217
240
244
264
265
269
275
295
299
308
309
320
321
342
351
389
404
449
468
476
487
502
520
544
556
563
578
580
581
589
593
598
609
610
623
626
631
650
663
668
669
670
679
695
714
740
741
748
759
774
775
794
79...

output:

1151

result:

ok single line: '1151'

Test #102:

score: 7
Accepted
time: 1ms
memory: 5596kb

input:

909 12 12 100
11
21
30
38
45
51
58
66
75
85
96
108
119
129
138
146
153
159
166
174
183
193
204
216
227
237
246
254
261
267
274
282
291
301
312
324
335
345
354
362
369
375
382
390
399
409
420
432
443
453
462
470
477
483
490
498
507
517
528
540
551
561
570
578
585
591
598
606
615
625
636
648
659
669
6...

output:

1207

result:

ok single line: '1207'

Test #103:

score: 7
Accepted
time: 1ms
memory: 5668kb

input:

909 12 13 100
11
21
30
38
45
51
58
66
75
85
96
108
119
129
138
146
153
159
166
174
183
193
204
216
227
237
246
254
261
267
274
282
291
301
312
324
335
345
354
362
369
375
382
390
399
409
420
432
443
453
462
470
477
483
490
498
507
517
528
540
551
561
570
578
585
591
598
606
615
625
636
648
659
669
6...

output:

1207

result:

ok single line: '1207'

Test #104:

score: 7
Accepted
time: 1ms
memory: 5632kb

input:

18 4 5 2
8
15

output:

29

result:

ok single line: '29'

Test #105:

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

input:

18 4 0 2
8
15

output:

18

result:

ok single line: '18'

Test #106:

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

input:

18 10 100 2
8
15

output:

20

result:

ok single line: '20'

Test #107:

score: 7
Accepted
time: 1ms
memory: 5724kb

input:

18 4 100 0

output:

418

result:

ok single line: '418'

Test #108:

score: 7
Accepted
time: 1ms
memory: 5724kb

input:

65 20 100 3
14
25
33

output:

172

result:

ok single line: '172'

Subtask #4:

score: 15
Accepted

Test #109:

score: 15
Accepted
time: 1ms
memory: 5604kb

input:

1000000000000 1 1000000 0

output:

1000000999999000000

result:

ok single line: '1000000999999000000'

Test #110:

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

input:

108 100 10000 5
10
20
30
40
98

output:

110

result:

ok single line: '110'

Test #111:

score: 15
Accepted
time: 1ms
memory: 5600kb

input:

118 100 10000 5
10
20
30
98
108

output:

120

result:

ok single line: '120'

Test #112:

score: 15
Accepted
time: 1ms
memory: 5724kb

input:

206 100 10000 5
10
20
30
98
196

output:

210

result:

ok single line: '210'

Test #113:

score: 15
Accepted
time: 1ms
memory: 5632kb

input:

128 100 10000 5
10
20
98
108
118

output:

130

result:

ok single line: '130'

Test #114:

score: 15
Accepted
time: 1ms
memory: 5660kb

input:

206 100 10000 5
10
20
98
108
196

output:

210

result:

ok single line: '210'

Test #115:

score: 15
Accepted
time: 1ms
memory: 5664kb

input:

216 100 10000 5
10
20
98
196
206

output:

220

result:

ok single line: '220'

Test #116:

score: 15
Accepted
time: 1ms
memory: 5592kb

input:

304 100 10000 5
10
20
98
196
294

output:

310

result:

ok single line: '310'

Test #117:

score: 15
Accepted
time: 1ms
memory: 5600kb

input:

138 100 10000 5
10
98
108
118
128

output:

140

result:

ok single line: '140'

Test #118:

score: 15
Accepted
time: 1ms
memory: 5608kb

input:

206 100 10000 5
10
98
108
118
196

output:

210

result:

ok single line: '210'

Test #119:

score: 15
Accepted
time: 1ms
memory: 5672kb

input:

216 100 10000 5
10
98
108
196
206

output:

220

result:

ok single line: '220'

Test #120:

score: 15
Accepted
time: 1ms
memory: 5604kb

input:

304 100 10000 5
10
98
108
196
294

output:

310

result:

ok single line: '310'

Test #121:

score: 15
Accepted
time: 1ms
memory: 5668kb

input:

226 100 10000 5
10
98
196
206
216

output:

230

result:

ok single line: '230'

Test #122:

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

input:

304 100 10000 5
10
98
196
206
294

output:

310

result:

ok single line: '310'

Test #123:

score: 15
Accepted
time: 1ms
memory: 5672kb

input:

314 100 10000 5
10
98
196
294
304

output:

320

result:

ok single line: '320'

Test #124:

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

input:

402 100 10000 5
10
98
196
294
392

output:

410

result:

ok single line: '410'

Test #125:

score: 15
Accepted
time: 1ms
memory: 5660kb

input:

148 100 10000 5
98
108
118
128
138

output:

150

result:

ok single line: '150'

Test #126:

score: 15
Accepted
time: 1ms
memory: 5640kb

input:

206 100 10000 5
98
108
118
128
196

output:

210

result:

ok single line: '210'

Test #127:

score: 15
Accepted
time: 1ms
memory: 5724kb

input:

216 100 10000 5
98
108
118
196
206

output:

220

result:

ok single line: '220'

Test #128:

score: 15
Accepted
time: 1ms
memory: 5612kb

input:

304 100 10000 5
98
108
118
196
294

output:

310

result:

ok single line: '310'

Test #129:

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

input:

226 100 10000 5
98
108
196
206
216

output:

230

result:

ok single line: '230'

Test #130:

score: 15
Accepted
time: 1ms
memory: 5736kb

input:

304 100 10000 5
98
108
196
206
294

output:

310

result:

ok single line: '310'

Test #131:

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

input:

314 100 10000 5
98
108
196
294
304

output:

320

result:

ok single line: '320'

Test #132:

score: 15
Accepted
time: 1ms
memory: 5608kb

input:

402 100 10000 5
98
108
196
294
392

output:

410

result:

ok single line: '410'

Test #133:

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

input:

236 100 10000 5
98
196
206
216
226

output:

240

result:

ok single line: '240'

Test #134:

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

input:

304 100 10000 5
98
196
206
216
294

output:

310

result:

ok single line: '310'

Test #135:

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

input:

314 100 10000 5
98
196
206
294
304

output:

320

result:

ok single line: '320'

Test #136:

score: 15
Accepted
time: 1ms
memory: 5612kb

input:

402 100 10000 5
98
196
206
294
392

output:

410

result:

ok single line: '410'

Test #137:

score: 15
Accepted
time: 1ms
memory: 5676kb

input:

324 100 10000 5
98
196
294
304
314

output:

330

result:

ok single line: '330'

Test #138:

score: 15
Accepted
time: 1ms
memory: 5668kb

input:

402 100 10000 5
98
196
294
304
392

output:

410

result:

ok single line: '410'

Test #139:

score: 15
Accepted
time: 1ms
memory: 5600kb

input:

412 100 10000 5
98
196
294
392
402

output:

420

result:

ok single line: '420'

Test #140:

score: 15
Accepted
time: 1ms
memory: 5660kb

input:

500 100 10000 5
98
196
294
392
490

output:

510

result:

ok single line: '510'

Test #141:

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

input:

10 2 10 2
1
3

output:

41

result:

ok single line: '41'

Test #142:

score: 15
Accepted
time: 1ms
memory: 5668kb

input:

100 21 10 2
5
54

output:

140

result:

ok single line: '140'

Test #143:

score: 15
Accepted
time: 1ms
memory: 5668kb

input:

100 21 10 9
18
21
53
62
85
86
88
90
91

output:

121

result:

ok single line: '121'

Test #144:

score: 15
Accepted
time: 1ms
memory: 5664kb

input:

100 21 10 10
30
39
40
43
45
49
52
57
70
72

output:

132

result:

ok single line: '132'

Test #145:

score: 15
Accepted
time: 1ms
memory: 5664kb

input:

156 20 1 10
19
37
54
70
85
99
112
124
135
145

output:

162

result:

ok single line: '162'

Test #146:

score: 15
Accepted
time: 1ms
memory: 5592kb

input:

156 20 20 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #147:

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

input:

156 20 30 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #148:

score: 15
Accepted
time: 1ms
memory: 5604kb

input:

10 2 10 0

output:

50

result:

ok single line: '50'

Test #149:

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

input:

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

output:

10

result:

ok single line: '10'

Test #150:

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

input:

10 2 10 3
2
4
6

output:

20

result:

ok single line: '20'

Test #151:

score: 15
Accepted
time: 1ms
memory: 5600kb

input:

100 2 10 33
2
5
6
9
10
12
18
26
29
30
32
34
35
42
49
50
52
53
55
56
58
61
62
63
69
71
73
74
82
89
91
93
94

output:

356

result:

ok single line: '356'

Test #152:

score: 15
Accepted
time: 1ms
memory: 5572kb

input:

100 2 10 50
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

output:

340

result:

ok single line: '340'

Test #153:

score: 15
Accepted
time: 1ms
memory: 5732kb

input:

100 2 10 50
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

output:

340

result:

ok single line: '340'

Test #154:

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

input:

100 2 10 50
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
61
63
65
67
69
71
73
75
77
79
81
83
85
87
89
91
93
95
97
99

output:

101

result:

ok single line: '101'

Test #155:

score: 15
Accepted
time: 1ms
memory: 5692kb

input:

1000 2 10 999
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:

1000

result:

ok single line: '1000'

Test #156:

score: 15
Accepted
time: 1ms
memory: 5584kb

input:

1000 42 15 100
9
10
31
35
39
42
53
68
75
77
78
92
117
121
123
141
146
147
157
166
167
193
221
222
231
247
255
265
275
292
305
313
341
343
344
352
357
364
371
380
388
392
410
417
418
445
450
451
452
460
476
479
485
498
501
505
515
524
532
539
542
565
569
570
580
581
585
593
607
618
633
634
642
661
66...

output:

1126

result:

ok single line: '1126'

Test #157:

score: 15
Accepted
time: 1ms
memory: 5608kb

input:

1000 42 14 100
8
15
24
35
46
60
71
98
102
113
125
126
159
164
181
183
191
199
208
212
216
217
240
244
264
265
269
275
295
299
308
309
320
321
342
351
389
404
449
468
476
487
502
520
544
556
563
578
580
581
589
593
598
609
610
623
626
631
650
663
668
669
670
679
695
714
740
741
748
759
774
775
794
79...

output:

1151

result:

ok single line: '1151'

Test #158:

score: 15
Accepted
time: 1ms
memory: 5660kb

input:

909 12 12 100
11
21
30
38
45
51
58
66
75
85
96
108
119
129
138
146
153
159
166
174
183
193
204
216
227
237
246
254
261
267
274
282
291
301
312
324
335
345
354
362
369
375
382
390
399
409
420
432
443
453
462
470
477
483
490
498
507
517
528
540
551
561
570
578
585
591
598
606
615
625
636
648
659
669
6...

output:

1207

result:

ok single line: '1207'

Test #159:

score: 15
Accepted
time: 1ms
memory: 5664kb

input:

909 12 13 100
11
21
30
38
45
51
58
66
75
85
96
108
119
129
138
146
153
159
166
174
183
193
204
216
227
237
246
254
261
267
274
282
291
301
312
324
335
345
354
362
369
375
382
390
399
409
420
432
443
453
462
470
477
483
490
498
507
517
528
540
551
561
570
578
585
591
598
606
615
625
636
648
659
669
6...

output:

1207

result:

ok single line: '1207'

Test #160:

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

input:

1000 2 10 333
1
11
12
14
18
19
20
21
22
23
25
27
36
41
43
44
50
54
56
61
64
66
67
69
70
73
74
76
81
83
85
92
95
97
99
115
117
125
126
127
128
137
140
145
148
150
153
156
158
161
165
166
168
169
173
178
179
180
184
187
191
192
195
197
198
201
202
204
205
209
212
213
214
215
218
223
226
227
228
231
23...

output:

3734

result:

ok single line: '3734'

Test #161:

score: 15
Accepted
time: 1ms
memory: 5676kb

input:

1000 2 10 333
2
3
5
6
7
9
10
11
14
15
16
18
19
20
21
25
28
32
33
36
37
38
39
42
43
44
45
46
47
48
49
52
54
56
57
58
59
61
62
63
64
65
66
68
72
73
74
75
76
77
79
80
82
83
84
85
86
87
88
91
92
94
95
96
97
98
100
101
102
103
106
107
109
110
112
117
118
120
121
124
126
128
129
130
133
134
135
136
137
14...

output:

3905

result:

ok single line: '3905'

Test #162:

score: 15
Accepted
time: 1ms
memory: 5632kb

input:

10000 1000 10 333
56
112
142
157
258
264
369
456
487
489
490
564
614
644
662
742
743
789
796
868
880
904
909
937
944
1025
1030
1050
1059
1075
1087
1106
1201
1223
1230
1251
1254
1264
1275
1283
1303
1345
1346
1412
1500
1547
1571
1580
1589
1606
1608
1673
1736
1874
1881
1886
1893
1899
1900
1965
1972
200...

output:

10080

result:

ok single line: '10080'

Test #163:

score: 15
Accepted
time: 1ms
memory: 5752kb

input:

10000 5112 10 333
100
109
114
153
179
217
259
308
335
427
605
613
654
690
693
718
748
756
792
802
803
834
902
939
993
1001
1067
1109
1130
1138
1140
1178
1185
1201
1220
1230
1256
1268
1302
1315
1318
1383
1385
1418
1437
1440
1490
1505
1524
1528
1588
1639
1716
1816
1895
1902
1969
1970
1998
2018
2019
21...

output:

10001

result:

ok single line: '10001'

Test #164:

score: 15
Accepted
time: 1ms
memory: 5692kb

input:

10000 5112 10 1000
38
43
86
95
100
109
139
145
162
171
172
233
238
246
250
253
255
272
279
282
301
302
303
317
323
335
345
359
389
395
412
422
426
428
429
430
433
447
462
463
466
487
510
517
524
525
534
553
562
589
595
597
600
604
608
612
614
617
631
633
634
637
650
652
654
661
665
692
703
720
723
7...

output:

10001

result:

ok single line: '10001'

Test #165:

score: 15
Accepted
time: 1ms
memory: 5684kb

input:

1000000 100000 10 1000
224
840
3558
4128
4843
5844
6725
7563
8609
10878
11518
11788
12665
17515
19679
20836
23523
25305
25969
26491
26784
28819
29060
30432
31553
32112
34761
35764
36283
36805
37998
39156
41818
41949
42030
43038
43418
45356
45498
46340
47055
47219
47245
47934
48860
49322
49651
50733
...

output:

1000090

result:

ok single line: '1000090'

Test #166:

score: 15
Accepted
time: 1ms
memory: 5748kb

input:

10000000 654321 10 1000
6994
17949
18560
22403
41203
52063
53122
54283
60440
74643
76906
89564
112801
126774
132985
138499
141721
147238
148151
162195
182328
196952
197300
228573
229302
254747
260542
266140
268993
272972
281824
284863
286848
287601
299086
324301
324347
364128
380064
380224
383010
39...

output:

10000150

result:

ok single line: '10000150'

Test #167:

score: 15
Accepted
time: 1ms
memory: 5756kb

input:

10000000 1000000 10 1000
8493
12143
22571
23844
53097
70069
70148
72263
99066
102909
109735
112082
118795
119991
161476
182047
182786
187171
187248
210425
213592
214748
230448
254567
295858
298656
310292
315378
324690
343069
366615
383635
407333
411398
417302
437047
449394
460060
461452
471160
47575...

output:

10000090

result:

ok single line: '10000090'

Test #168:

score: 15
Accepted
time: 1ms
memory: 5604kb

input:

10000 42 8 100
101
337
363
512
585
700
709
831
896
954
1000
1137
1203
1255
1419
1464
1574
1711
1947
1955
2037
2104
2292
2550
2631
2748
2788
2861
2866
2878
2888
3169
3497
3507
3536
3684
3773
3854
3886
4010
4041
4061
4101
4155
4210
4292
4355
4468
4554
4737
4742
4832
4892
4997
5028
5295
5486
5507
5516
...

output:

11781

result:

ok single line: '11781'

Test #169:

score: 15
Accepted
time: 1ms
memory: 5764kb

input:

10000 42 10 1000
11
19
32
38
65
71
77
78
81
91
119
126
138
146
167
172
183
186
192
199
204
211
215
218
220
221
226
228
299
304
319
323
332
353
368
372
377
402
405
414
416
432
470
504
509
515
554
555
566
571
595
596
605
607
634
637
642
654
655
667
697
711
721
723
724
731
733
744
753
760
783
789
796
8...

output:

11093

result:

ok single line: '11093'

Test #170:

score: 15
Accepted
time: 1ms
memory: 5612kb

input:

10000 42 42 1000
14
26
34
47
53
54
75
82
104
107
114
122
126
144
146
148
172
173
204
232
241
247
277
279
285
290
307
316
319
329
335
343
348
356
369
370
377
382
392
427
434
439
456
492
499
500
520
526
533
536
537
547
548
555
557
561
579
586
596
599
605
619
620
624
633
658
665
668
715
747
754
757
761...

output:

12580

result:

ok single line: '12580'

Test #171:

score: 15
Accepted
time: 1ms
memory: 5636kb

input:

10000 100 50 1000
4
35
40
46
50
54
59
70
81
82
83
84
85
100
115
126
140
143
162
176
185
186
195
211
224
237
246
247
253
255
256
272
279
286
306
315
316
319
325
335
345
351
361
384
389
397
410
413
414
426
431
434
450
455
476
478
479
516
527
531
534
537
561
564
576
594
596
599
601
603
615
621
627
632
...

output:

10889

result:

ok single line: '10889'

Test #172:

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

input:

375499 500 500 1000
499
997
1494
1990
2485
2979
3472
3964
4455
4945
5434
5922
6409
6895
7380
7864
8347
8829
9310
9790
10269
10747
11224
11700
12175
12649
13122
13594
14065
14535
15004
15472
15939
16405
16870
17334
17797
18259
18720
19180
19639
20097
20554
21010
21465
21919
22372
22824
23275
23725
24...

output:

500499

result:

ok single line: '500499'

Test #173:

score: 15
Accepted
time: 1ms
memory: 5776kb

input:

375499 500 501 1000
499
997
1494
1990
2485
2979
3472
3964
4455
4945
5434
5922
6409
6895
7380
7864
8347
8829
9310
9790
10269
10747
11224
11700
12175
12649
13122
13594
14065
14535
15004
15472
15939
16405
16870
17334
17797
18259
18720
19180
19639
20097
20554
21010
21465
21919
22372
22824
23275
23725
24...

output:

500499

result:

ok single line: '500499'

Test #174:

score: 15
Accepted
time: 1ms
memory: 5604kb

input:

18 4 5 2
8
15

output:

29

result:

ok single line: '29'

Test #175:

score: 15
Accepted
time: 1ms
memory: 5600kb

input:

18 4 0 2
8
15

output:

18

result:

ok single line: '18'

Test #176:

score: 15
Accepted
time: 1ms
memory: 5660kb

input:

18 10 100 2
8
15

output:

20

result:

ok single line: '20'

Test #177:

score: 15
Accepted
time: 1ms
memory: 5668kb

input:

18 4 100 0

output:

418

result:

ok single line: '418'

Test #178:

score: 15
Accepted
time: 1ms
memory: 5656kb

input:

65 20 100 3
14
25
33

output:

172

result:

ok single line: '172'

Subtask #5:

score: 20
Accepted

Dependency #2:

100%
Accepted

Test #179:

score: 20
Accepted
time: 1ms
memory: 5668kb

input:

1000000000000 1 1000000 0

output:

1000000999999000000

result:

ok single line: '1000000999999000000'

Test #180:

score: 20
Accepted
time: 0ms
memory: 5672kb

input:

108 100 10000 5
10
20
30
40
98

output:

110

result:

ok single line: '110'

Test #181:

score: 20
Accepted
time: 1ms
memory: 5596kb

input:

118 100 10000 5
10
20
30
98
108

output:

120

result:

ok single line: '120'

Test #182:

score: 20
Accepted
time: 1ms
memory: 5660kb

input:

206 100 10000 5
10
20
30
98
196

output:

210

result:

ok single line: '210'

Test #183:

score: 20
Accepted
time: 1ms
memory: 5620kb

input:

128 100 10000 5
10
20
98
108
118

output:

130

result:

ok single line: '130'

Test #184:

score: 20
Accepted
time: 1ms
memory: 5600kb

input:

206 100 10000 5
10
20
98
108
196

output:

210

result:

ok single line: '210'

Test #185:

score: 20
Accepted
time: 1ms
memory: 5596kb

input:

216 100 10000 5
10
20
98
196
206

output:

220

result:

ok single line: '220'

Test #186:

score: 20
Accepted
time: 1ms
memory: 5604kb

input:

304 100 10000 5
10
20
98
196
294

output:

310

result:

ok single line: '310'

Test #187:

score: 20
Accepted
time: 1ms
memory: 5596kb

input:

138 100 10000 5
10
98
108
118
128

output:

140

result:

ok single line: '140'

Test #188:

score: 20
Accepted
time: 1ms
memory: 5668kb

input:

206 100 10000 5
10
98
108
118
196

output:

210

result:

ok single line: '210'

Test #189:

score: 20
Accepted
time: 0ms
memory: 5724kb

input:

216 100 10000 5
10
98
108
196
206

output:

220

result:

ok single line: '220'

Test #190:

score: 20
Accepted
time: 1ms
memory: 5664kb

input:

304 100 10000 5
10
98
108
196
294

output:

310

result:

ok single line: '310'

Test #191:

score: 20
Accepted
time: 1ms
memory: 5660kb

input:

226 100 10000 5
10
98
196
206
216

output:

230

result:

ok single line: '230'

Test #192:

score: 20
Accepted
time: 1ms
memory: 5600kb

input:

304 100 10000 5
10
98
196
206
294

output:

310

result:

ok single line: '310'

Test #193:

score: 20
Accepted
time: 0ms
memory: 5600kb

input:

314 100 10000 5
10
98
196
294
304

output:

320

result:

ok single line: '320'

Test #194:

score: 20
Accepted
time: 1ms
memory: 5732kb

input:

402 100 10000 5
10
98
196
294
392

output:

410

result:

ok single line: '410'

Test #195:

score: 20
Accepted
time: 1ms
memory: 5604kb

input:

148 100 10000 5
98
108
118
128
138

output:

150

result:

ok single line: '150'

Test #196:

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

input:

206 100 10000 5
98
108
118
128
196

output:

210

result:

ok single line: '210'

Test #197:

score: 20
Accepted
time: 0ms
memory: 5632kb

input:

216 100 10000 5
98
108
118
196
206

output:

220

result:

ok single line: '220'

Test #198:

score: 20
Accepted
time: 0ms
memory: 5732kb

input:

304 100 10000 5
98
108
118
196
294

output:

310

result:

ok single line: '310'

Test #199:

score: 20
Accepted
time: 1ms
memory: 5668kb

input:

226 100 10000 5
98
108
196
206
216

output:

230

result:

ok single line: '230'

Test #200:

score: 20
Accepted
time: 1ms
memory: 5664kb

input:

304 100 10000 5
98
108
196
206
294

output:

310

result:

ok single line: '310'

Test #201:

score: 20
Accepted
time: 1ms
memory: 5672kb

input:

314 100 10000 5
98
108
196
294
304

output:

320

result:

ok single line: '320'

Test #202:

score: 20
Accepted
time: 1ms
memory: 5672kb

input:

402 100 10000 5
98
108
196
294
392

output:

410

result:

ok single line: '410'

Test #203:

score: 20
Accepted
time: 1ms
memory: 5668kb

input:

236 100 10000 5
98
196
206
216
226

output:

240

result:

ok single line: '240'

Test #204:

score: 20
Accepted
time: 1ms
memory: 5596kb

input:

304 100 10000 5
98
196
206
216
294

output:

310

result:

ok single line: '310'

Test #205:

score: 20
Accepted
time: 0ms
memory: 5604kb

input:

314 100 10000 5
98
196
206
294
304

output:

320

result:

ok single line: '320'

Test #206:

score: 20
Accepted
time: 1ms
memory: 5664kb

input:

402 100 10000 5
98
196
206
294
392

output:

410

result:

ok single line: '410'

Test #207:

score: 20
Accepted
time: 1ms
memory: 5600kb

input:

324 100 10000 5
98
196
294
304
314

output:

330

result:

ok single line: '330'

Test #208:

score: 20
Accepted
time: 1ms
memory: 5596kb

input:

402 100 10000 5
98
196
294
304
392

output:

410

result:

ok single line: '410'

Test #209:

score: 20
Accepted
time: 0ms
memory: 5604kb

input:

412 100 10000 5
98
196
294
392
402

output:

420

result:

ok single line: '420'

Test #210:

score: 20
Accepted
time: 1ms
memory: 5600kb

input:

500 100 10000 5
98
196
294
392
490

output:

510

result:

ok single line: '510'

Test #211:

score: 20
Accepted
time: 1ms
memory: 5628kb

input:

10 2 10 2
1
3

output:

41

result:

ok single line: '41'

Test #212:

score: 20
Accepted
time: 1ms
memory: 5668kb

input:

100 21 10 2
5
54

output:

140

result:

ok single line: '140'

Test #213:

score: 20
Accepted
time: 1ms
memory: 5596kb

input:

100 21 10 9
18
21
53
62
85
86
88
90
91

output:

121

result:

ok single line: '121'

Test #214:

score: 20
Accepted
time: 0ms
memory: 5628kb

input:

100 21 10 10
30
39
40
43
45
49
52
57
70
72

output:

132

result:

ok single line: '132'

Test #215:

score: 20
Accepted
time: 1ms
memory: 5600kb

input:

156 20 1 10
19
37
54
70
85
99
112
124
135
145

output:

162

result:

ok single line: '162'

Test #216:

score: 20
Accepted
time: 0ms
memory: 5660kb

input:

156 20 20 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #217:

score: 20
Accepted
time: 1ms
memory: 5732kb

input:

156 20 30 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #218:

score: 20
Accepted
time: 18ms
memory: 8824kb

input:

1000000 100 10 100000
1
8
9
10
12
16
17
20
21
22
23
24
28
30
31
32
34
37
38
41
48
51
58
59
61
63
66
68
70
73
77
79
80
81
82
85
89
90
91
92
96
97
99
100
101
102
105
109
110
111
112
114
115
117
120
123
126
127
130
134
138
139
141
142
144
145
149
150
158
160
161
162
167
169
170
174
175
178
182
185
187
...

output:

1081682

result:

ok single line: '1081682'

Test #219:

score: 20
Accepted
time: 16ms
memory: 8772kb

input:

1000000 100 10 100000
10
14
18
21
22
27
40
42
50
59
105
114
132
142
151
152
166
190
196
197
202
205
210
222
238
241
259
287
288
293
304
309
321
340
350
368
384
385
417
427
437
491
498
526
530
555
556
570
576
589
600
610
620
635
642
644
666
708
709
710
718
727
730
749
751
763
770
782
811
813
815
816
...

output:

1047315

result:

ok single line: '1047315'

Test #220:

score: 20
Accepted
time: 1ms
memory: 5696kb

input:

1000000 100 8 1000
39
1562
1649
2355
4738
4889
5142
5261
5649
6214
8152
8899
11790
11870
12496
12920
13274
13996
14469
14584
18250
18558
18721
21209
26066
26370
26467
27204
28674
28739
30820
31931
32616
36035
36273
38274
39402
39478
41017
41088
43831
43989
45860
46628
46890
49500
51612
52134
52298
5...

output:

1079383

result:

ok single line: '1079383'

Test #221:

score: 20
Accepted
time: 1ms
memory: 5700kb

input:

1000000 100 25 1000
358
1131
1624
2168
2197
3061
3352
3720
3724
3827
4886
5151
5211
8470
10498
11335
13236
13844
14420
15046
15327
16217
17619
18234
18244
19212
20943
21464
21836
22292
23847
24140
25412
27162
27692
30075
32753
33232
35108
35629
35995
38608
39475
40188
40294
40988
41281
41464
41849
4...

output:

1245648

result:

ok single line: '1245648'

Test #222:

score: 20
Accepted
time: 1ms
memory: 5696kb

input:

1000000 100 50 1000
4919
6240
8211
8257
9364
12447
13429
13497
15222
15796
16384
17405
17565
17645
19549
20799
22133
26147
26661
26693
27934
30937
33712
34681
34952
35577
38573
40010
40582
40760
41303
41342
41578
46052
48398
49197
49253
49514
49556
51014
51217
51777
53168
53734
53856
55366
56381
578...

output:

1486984

result:

ok single line: '1486984'

Test #223:

score: 20
Accepted
time: 16ms
memory: 6744kb

input:

7500099 100 100 100000
99
197
294
390
485
579
672
764
855
945
1034
1122
1209
1295
1380
1464
1547
1629
1710
1790
1869
1947
2024
2100
2175
2249
2322
2394
2465
2535
2604
2672
2739
2805
2870
2934
2997
3059
3120
3180
3239
3297
3354
3410
3465
3519
3572
3624
3675
3725
3776
3828
3881
3935
3990
4046
4103
416...

output:

10000099

result:

ok single line: '10000099'

Test #224:

score: 20
Accepted
time: 14ms
memory: 8860kb

input:

7500099 100 101 100000
99
197
294
390
485
579
672
764
855
945
1034
1122
1209
1295
1380
1464
1547
1629
1710
1790
1869
1947
2024
2100
2175
2249
2322
2394
2465
2535
2604
2672
2739
2805
2870
2934
2997
3059
3120
3180
3239
3297
3354
3410
3465
3519
3572
3624
3675
3725
3776
3828
3881
3935
3990
4046
4103
416...

output:

10000099

result:

ok single line: '10000099'

Test #225:

score: 20
Accepted
time: 0ms
memory: 5660kb

input:

18 4 5 2
8
15

output:

29

result:

ok single line: '29'

Test #226:

score: 20
Accepted
time: 0ms
memory: 5672kb

input:

18 4 0 2
8
15

output:

18

result:

ok single line: '18'

Test #227:

score: 20
Accepted
time: 0ms
memory: 5724kb

input:

18 10 100 2
8
15

output:

20

result:

ok single line: '20'

Test #228:

score: 20
Accepted
time: 1ms
memory: 5724kb

input:

18 4 100 0

output:

418

result:

ok single line: '418'

Test #229:

score: 20
Accepted
time: 1ms
memory: 5608kb

input:

65 20 100 3
14
25
33

output:

172

result:

ok single line: '172'

Subtask #6:

score: 35
Accepted

Dependency #1:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #230:

score: 35
Accepted
time: 1ms
memory: 5636kb

input:

1000000000000 1 1000000 0

output:

1000000999999000000

result:

ok single line: '1000000999999000000'

Test #231:

score: 35
Accepted
time: 1ms
memory: 5604kb

input:

100 10 11 10
10
11
20
30
38
49
50
60
70
90

output:

122

result:

ok single line: '122'

Test #232:

score: 35
Accepted
time: 1ms
memory: 5696kb

input:

100 10 11 15
1
5
9
15
24
25
39
40
45
66
75
79
85
95
97

output:

138

result:

ok single line: '138'

Test #233:

score: 35
Accepted
time: 1ms
memory: 5724kb

input:

100000 1000 123 1000
20
25
139
161
312
336
379
472
780
803
1000
1117
1132
1159
1411
1429
1430
1623
1964
2000
2266
2284
2537
2717
2963
3000
3153
3217
3400
3462
3477
3525
3542
3711
3754
3946
3958
4000
4091
4102
4131
4458
4649
4661
4804
4883
4898
4913
4979
5000
5210
5243
5357
5383
5393
5441
5627
5969
6...

output:

100984

result:

ok single line: '100984'

Test #234:

score: 35
Accepted
time: 1ms
memory: 5688kb

input:

100000 100 123 1000
409
858
938
958
1058
1125
1148
1158
1175
1258
1307
1310
1358
1458
1597
1658
1743
1758
1858
2058
2092
2258
2343
2358
2444
2458
2558
2658
2690
2758
2806
2845
2958
3058
3091
3151
3258
3358
3474
3558
3658
3758
3992
4158
4258
4358
4458
4718
5039
5058
5227
5458
5758
5797
5858
5928
5958...

output:

153301

result:

ok single line: '153301'

Test #235:

score: 35
Accepted
time: 11ms
memory: 10592kb

input:

1000000000000 1000000 12345 100000
14000000
22000000
24000000
32000000
44000000
56000000
74000000
87000000
98000000
106000000
126000000
132000000
146000000
171000000
174000000
177000000
195000000
208000000
223000000
224000000
230000000
232000000
246000000
257000000
279000000
282000000
283000000
3200...

output:

1011111722155

result:

ok single line: '1011111722155'

Test #236:

score: 35
Accepted
time: 29ms
memory: 10888kb

input:

1000000000000 1000000 12345 100000
95
241
461
643
755
955
957
1000
1003
1154
1414
1555
1584
1626
1951
2018
2105
2121
2249
2253
2281
2405
2438
2472
2562
2815
2863
2892
2972
3070
3298
3352
3414
3537
3581
3664
3717
4092
4096
4101
4324
4572
4645
4758
4874
4905
4927
4981
5238
5372
5426
5545
5733
5778
604...

output:

1011233973415

result:

ok single line: '1011233973415'

Test #237:

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

input:

108 100 10000 5
10
20
30
40
98

output:

110

result:

ok single line: '110'

Test #238:

score: 35
Accepted
time: 1ms
memory: 5664kb

input:

118 100 10000 5
10
20
30
98
108

output:

120

result:

ok single line: '120'

Test #239:

score: 35
Accepted
time: 1ms
memory: 5720kb

input:

206 100 10000 5
10
20
30
98
196

output:

210

result:

ok single line: '210'

Test #240:

score: 35
Accepted
time: 1ms
memory: 5600kb

input:

128 100 10000 5
10
20
98
108
118

output:

130

result:

ok single line: '130'

Test #241:

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

input:

206 100 10000 5
10
20
98
108
196

output:

210

result:

ok single line: '210'

Test #242:

score: 35
Accepted
time: 1ms
memory: 5668kb

input:

216 100 10000 5
10
20
98
196
206

output:

220

result:

ok single line: '220'

Test #243:

score: 35
Accepted
time: 1ms
memory: 5600kb

input:

304 100 10000 5
10
20
98
196
294

output:

310

result:

ok single line: '310'

Test #244:

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

input:

138 100 10000 5
10
98
108
118
128

output:

140

result:

ok single line: '140'

Test #245:

score: 35
Accepted
time: 1ms
memory: 5732kb

input:

206 100 10000 5
10
98
108
118
196

output:

210

result:

ok single line: '210'

Test #246:

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

input:

216 100 10000 5
10
98
108
196
206

output:

220

result:

ok single line: '220'

Test #247:

score: 35
Accepted
time: 1ms
memory: 5660kb

input:

304 100 10000 5
10
98
108
196
294

output:

310

result:

ok single line: '310'

Test #248:

score: 35
Accepted
time: 1ms
memory: 5668kb

input:

226 100 10000 5
10
98
196
206
216

output:

230

result:

ok single line: '230'

Test #249:

score: 35
Accepted
time: 1ms
memory: 5668kb

input:

304 100 10000 5
10
98
196
206
294

output:

310

result:

ok single line: '310'

Test #250:

score: 35
Accepted
time: 1ms
memory: 5728kb

input:

314 100 10000 5
10
98
196
294
304

output:

320

result:

ok single line: '320'

Test #251:

score: 35
Accepted
time: 1ms
memory: 5728kb

input:

402 100 10000 5
10
98
196
294
392

output:

410

result:

ok single line: '410'

Test #252:

score: 35
Accepted
time: 1ms
memory: 5600kb

input:

148 100 10000 5
98
108
118
128
138

output:

150

result:

ok single line: '150'

Test #253:

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

input:

206 100 10000 5
98
108
118
128
196

output:

210

result:

ok single line: '210'

Test #254:

score: 35
Accepted
time: 1ms
memory: 5664kb

input:

216 100 10000 5
98
108
118
196
206

output:

220

result:

ok single line: '220'

Test #255:

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

input:

304 100 10000 5
98
108
118
196
294

output:

310

result:

ok single line: '310'

Test #256:

score: 35
Accepted
time: 1ms
memory: 5632kb

input:

226 100 10000 5
98
108
196
206
216

output:

230

result:

ok single line: '230'

Test #257:

score: 35
Accepted
time: 1ms
memory: 5664kb

input:

304 100 10000 5
98
108
196
206
294

output:

310

result:

ok single line: '310'

Test #258:

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

input:

314 100 10000 5
98
108
196
294
304

output:

320

result:

ok single line: '320'

Test #259:

score: 35
Accepted
time: 1ms
memory: 5668kb

input:

402 100 10000 5
98
108
196
294
392

output:

410

result:

ok single line: '410'

Test #260:

score: 35
Accepted
time: 1ms
memory: 5668kb

input:

236 100 10000 5
98
196
206
216
226

output:

240

result:

ok single line: '240'

Test #261:

score: 35
Accepted
time: 1ms
memory: 5600kb

input:

304 100 10000 5
98
196
206
216
294

output:

310

result:

ok single line: '310'

Test #262:

score: 35
Accepted
time: 1ms
memory: 5596kb

input:

314 100 10000 5
98
196
206
294
304

output:

320

result:

ok single line: '320'

Test #263:

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

input:

402 100 10000 5
98
196
206
294
392

output:

410

result:

ok single line: '410'

Test #264:

score: 35
Accepted
time: 1ms
memory: 5596kb

input:

324 100 10000 5
98
196
294
304
314

output:

330

result:

ok single line: '330'

Test #265:

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

input:

402 100 10000 5
98
196
294
304
392

output:

410

result:

ok single line: '410'

Test #266:

score: 35
Accepted
time: 1ms
memory: 5600kb

input:

412 100 10000 5
98
196
294
392
402

output:

420

result:

ok single line: '420'

Test #267:

score: 35
Accepted
time: 1ms
memory: 5696kb

input:

500 100 10000 5
98
196
294
392
490

output:

510

result:

ok single line: '510'

Test #268:

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

input:

10 2 10 2
1
3

output:

41

result:

ok single line: '41'

Test #269:

score: 35
Accepted
time: 1ms
memory: 5664kb

input:

100 21 10 2
5
54

output:

140

result:

ok single line: '140'

Test #270:

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

input:

100 21 10 9
18
21
53
62
85
86
88
90
91

output:

121

result:

ok single line: '121'

Test #271:

score: 35
Accepted
time: 1ms
memory: 5664kb

input:

100 21 10 10
30
39
40
43
45
49
52
57
70
72

output:

132

result:

ok single line: '132'

Test #272:

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

input:

156 20 1 10
19
37
54
70
85
99
112
124
135
145

output:

162

result:

ok single line: '162'

Test #273:

score: 35
Accepted
time: 1ms
memory: 5600kb

input:

156 20 20 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #274:

score: 35
Accepted
time: 1ms
memory: 5664kb

input:

156 20 30 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #275:

score: 35
Accepted
time: 1ms
memory: 5668kb

input:

10 2 10 0

output:

50

result:

ok single line: '50'

Test #276:

score: 35
Accepted
time: 1ms
memory: 5676kb

input:

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

output:

10

result:

ok single line: '10'

Test #277:

score: 35
Accepted
time: 1ms
memory: 5736kb

input:

10 2 10 3
2
4
6

output:

20

result:

ok single line: '20'

Test #278:

score: 35
Accepted
time: 1ms
memory: 5604kb

input:

100 2 10 33
2
5
6
9
10
12
18
26
29
30
32
34
35
42
49
50
52
53
55
56
58
61
62
63
69
71
73
74
82
89
91
93
94

output:

356

result:

ok single line: '356'

Test #279:

score: 35
Accepted
time: 1ms
memory: 5604kb

input:

100 2 10 50
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

output:

340

result:

ok single line: '340'

Test #280:

score: 35
Accepted
time: 1ms
memory: 5732kb

input:

100 2 10 50
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

output:

340

result:

ok single line: '340'

Test #281:

score: 35
Accepted
time: 1ms
memory: 5604kb

input:

100 2 10 50
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
61
63
65
67
69
71
73
75
77
79
81
83
85
87
89
91
93
95
97
99

output:

101

result:

ok single line: '101'

Test #282:

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

input:

1000 2 10 999
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:

1000

result:

ok single line: '1000'

Test #283:

score: 35
Accepted
time: 1ms
memory: 5680kb

input:

1000 42 15 100
9
10
31
35
39
42
53
68
75
77
78
92
117
121
123
141
146
147
157
166
167
193
221
222
231
247
255
265
275
292
305
313
341
343
344
352
357
364
371
380
388
392
410
417
418
445
450
451
452
460
476
479
485
498
501
505
515
524
532
539
542
565
569
570
580
581
585
593
607
618
633
634
642
661
66...

output:

1126

result:

ok single line: '1126'

Test #284:

score: 35
Accepted
time: 1ms
memory: 5604kb

input:

1000 42 14 100
8
15
24
35
46
60
71
98
102
113
125
126
159
164
181
183
191
199
208
212
216
217
240
244
264
265
269
275
295
299
308
309
320
321
342
351
389
404
449
468
476
487
502
520
544
556
563
578
580
581
589
593
598
609
610
623
626
631
650
663
668
669
670
679
695
714
740
741
748
759
774
775
794
79...

output:

1151

result:

ok single line: '1151'

Test #285:

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

input:

909 12 12 100
11
21
30
38
45
51
58
66
75
85
96
108
119
129
138
146
153
159
166
174
183
193
204
216
227
237
246
254
261
267
274
282
291
301
312
324
335
345
354
362
369
375
382
390
399
409
420
432
443
453
462
470
477
483
490
498
507
517
528
540
551
561
570
578
585
591
598
606
615
625
636
648
659
669
6...

output:

1207

result:

ok single line: '1207'

Test #286:

score: 35
Accepted
time: 1ms
memory: 5728kb

input:

909 12 13 100
11
21
30
38
45
51
58
66
75
85
96
108
119
129
138
146
153
159
166
174
183
193
204
216
227
237
246
254
261
267
274
282
291
301
312
324
335
345
354
362
369
375
382
390
399
409
420
432
443
453
462
470
477
483
490
498
507
517
528
540
551
561
570
578
585
591
598
606
615
625
636
648
659
669
6...

output:

1207

result:

ok single line: '1207'

Test #287:

score: 35
Accepted
time: 1ms
memory: 5608kb

input:

1000 2 10 333
1
11
12
14
18
19
20
21
22
23
25
27
36
41
43
44
50
54
56
61
64
66
67
69
70
73
74
76
81
83
85
92
95
97
99
115
117
125
126
127
128
137
140
145
148
150
153
156
158
161
165
166
168
169
173
178
179
180
184
187
191
192
195
197
198
201
202
204
205
209
212
213
214
215
218
223
226
227
228
231
23...

output:

3734

result:

ok single line: '3734'

Test #288:

score: 35
Accepted
time: 1ms
memory: 5612kb

input:

1000 2 10 333
2
3
5
6
7
9
10
11
14
15
16
18
19
20
21
25
28
32
33
36
37
38
39
42
43
44
45
46
47
48
49
52
54
56
57
58
59
61
62
63
64
65
66
68
72
73
74
75
76
77
79
80
82
83
84
85
86
87
88
91
92
94
95
96
97
98
100
101
102
103
106
107
109
110
112
117
118
120
121
124
126
128
129
130
133
134
135
136
137
14...

output:

3905

result:

ok single line: '3905'

Test #289:

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

input:

10000 1000 10 333
56
112
142
157
258
264
369
456
487
489
490
564
614
644
662
742
743
789
796
868
880
904
909
937
944
1025
1030
1050
1059
1075
1087
1106
1201
1223
1230
1251
1254
1264
1275
1283
1303
1345
1346
1412
1500
1547
1571
1580
1589
1606
1608
1673
1736
1874
1881
1886
1893
1899
1900
1965
1972
200...

output:

10080

result:

ok single line: '10080'

Test #290:

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

input:

10000 5112 10 333
100
109
114
153
179
217
259
308
335
427
605
613
654
690
693
718
748
756
792
802
803
834
902
939
993
1001
1067
1109
1130
1138
1140
1178
1185
1201
1220
1230
1256
1268
1302
1315
1318
1383
1385
1418
1437
1440
1490
1505
1524
1528
1588
1639
1716
1816
1895
1902
1969
1970
1998
2018
2019
21...

output:

10001

result:

ok single line: '10001'

Test #291:

score: 35
Accepted
time: 1ms
memory: 5756kb

input:

10000 5112 10 1000
38
43
86
95
100
109
139
145
162
171
172
233
238
246
250
253
255
272
279
282
301
302
303
317
323
335
345
359
389
395
412
422
426
428
429
430
433
447
462
463
466
487
510
517
524
525
534
553
562
589
595
597
600
604
608
612
614
617
631
633
634
637
650
652
654
661
665
692
703
720
723
7...

output:

10001

result:

ok single line: '10001'

Test #292:

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

input:

1000000 100000 10 1000
224
840
3558
4128
4843
5844
6725
7563
8609
10878
11518
11788
12665
17515
19679
20836
23523
25305
25969
26491
26784
28819
29060
30432
31553
32112
34761
35764
36283
36805
37998
39156
41818
41949
42030
43038
43418
45356
45498
46340
47055
47219
47245
47934
48860
49322
49651
50733
...

output:

1000090

result:

ok single line: '1000090'

Test #293:

score: 35
Accepted
time: 1ms
memory: 5756kb

input:

10000000 654321 10 1000
6994
17949
18560
22403
41203
52063
53122
54283
60440
74643
76906
89564
112801
126774
132985
138499
141721
147238
148151
162195
182328
196952
197300
228573
229302
254747
260542
266140
268993
272972
281824
284863
286848
287601
299086
324301
324347
364128
380064
380224
383010
39...

output:

10000150

result:

ok single line: '10000150'

Test #294:

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

input:

10000000 1000000 10 1000
8493
12143
22571
23844
53097
70069
70148
72263
99066
102909
109735
112082
118795
119991
161476
182047
182786
187171
187248
210425
213592
214748
230448
254567
295858
298656
310292
315378
324690
343069
366615
383635
407333
411398
417302
437047
449394
460060
461452
471160
47575...

output:

10000090

result:

ok single line: '10000090'

Test #295:

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

input:

10000 42 8 100
101
337
363
512
585
700
709
831
896
954
1000
1137
1203
1255
1419
1464
1574
1711
1947
1955
2037
2104
2292
2550
2631
2748
2788
2861
2866
2878
2888
3169
3497
3507
3536
3684
3773
3854
3886
4010
4041
4061
4101
4155
4210
4292
4355
4468
4554
4737
4742
4832
4892
4997
5028
5295
5486
5507
5516
...

output:

11781

result:

ok single line: '11781'

Test #296:

score: 35
Accepted
time: 1ms
memory: 5688kb

input:

10000 42 10 1000
11
19
32
38
65
71
77
78
81
91
119
126
138
146
167
172
183
186
192
199
204
211
215
218
220
221
226
228
299
304
319
323
332
353
368
372
377
402
405
414
416
432
470
504
509
515
554
555
566
571
595
596
605
607
634
637
642
654
655
667
697
711
721
723
724
731
733
744
753
760
783
789
796
8...

output:

11093

result:

ok single line: '11093'

Test #297:

score: 35
Accepted
time: 1ms
memory: 5696kb

input:

10000 42 42 1000
14
26
34
47
53
54
75
82
104
107
114
122
126
144
146
148
172
173
204
232
241
247
277
279
285
290
307
316
319
329
335
343
348
356
369
370
377
382
392
427
434
439
456
492
499
500
520
526
533
536
537
547
548
555
557
561
579
586
596
599
605
619
620
624
633
658
665
668
715
747
754
757
761...

output:

12580

result:

ok single line: '12580'

Test #298:

score: 35
Accepted
time: 1ms
memory: 5700kb

input:

10000 100 50 1000
4
35
40
46
50
54
59
70
81
82
83
84
85
100
115
126
140
143
162
176
185
186
195
211
224
237
246
247
253
255
256
272
279
286
306
315
316
319
325
335
345
351
361
384
389
397
410
413
414
426
431
434
450
455
476
478
479
516
527
531
534
537
561
564
576
594
596
599
601
603
615
621
627
632
...

output:

10889

result:

ok single line: '10889'

Test #299:

score: 35
Accepted
time: 1ms
memory: 5720kb

input:

375499 500 500 1000
499
997
1494
1990
2485
2979
3472
3964
4455
4945
5434
5922
6409
6895
7380
7864
8347
8829
9310
9790
10269
10747
11224
11700
12175
12649
13122
13594
14065
14535
15004
15472
15939
16405
16870
17334
17797
18259
18720
19180
19639
20097
20554
21010
21465
21919
22372
22824
23275
23725
24...

output:

500499

result:

ok single line: '500499'

Test #300:

score: 35
Accepted
time: 1ms
memory: 5708kb

input:

375499 500 501 1000
499
997
1494
1990
2485
2979
3472
3964
4455
4945
5434
5922
6409
6895
7380
7864
8347
8829
9310
9790
10269
10747
11224
11700
12175
12649
13122
13594
14065
14535
15004
15472
15939
16405
16870
17334
17797
18259
18720
19180
19639
20097
20554
21010
21465
21919
22372
22824
23275
23725
24...

output:

500499

result:

ok single line: '500499'

Test #301:

score: 35
Accepted
time: 18ms
memory: 6748kb

input:

1000000 100 10 100000
1
8
9
10
12
16
17
20
21
22
23
24
28
30
31
32
34
37
38
41
48
51
58
59
61
63
66
68
70
73
77
79
80
81
82
85
89
90
91
92
96
97
99
100
101
102
105
109
110
111
112
114
115
117
120
123
126
127
130
134
138
139
141
142
144
145
149
150
158
160
161
162
167
169
170
174
175
178
182
185
187
...

output:

1081682

result:

ok single line: '1081682'

Test #302:

score: 35
Accepted
time: 20ms
memory: 8836kb

input:

1000000 100 10 100000
10
14
18
21
22
27
40
42
50
59
105
114
132
142
151
152
166
190
196
197
202
205
210
222
238
241
259
287
288
293
304
309
321
340
350
368
384
385
417
427
437
491
498
526
530
555
556
570
576
589
600
610
620
635
642
644
666
708
709
710
718
727
730
749
751
763
770
782
811
813
815
816
...

output:

1047315

result:

ok single line: '1047315'

Test #303:

score: 35
Accepted
time: 1ms
memory: 5628kb

input:

1000000 100 8 1000
39
1562
1649
2355
4738
4889
5142
5261
5649
6214
8152
8899
11790
11870
12496
12920
13274
13996
14469
14584
18250
18558
18721
21209
26066
26370
26467
27204
28674
28739
30820
31931
32616
36035
36273
38274
39402
39478
41017
41088
43831
43989
45860
46628
46890
49500
51612
52134
52298
5...

output:

1079383

result:

ok single line: '1079383'

Test #304:

score: 35
Accepted
time: 1ms
memory: 5756kb

input:

1000000 100 25 1000
358
1131
1624
2168
2197
3061
3352
3720
3724
3827
4886
5151
5211
8470
10498
11335
13236
13844
14420
15046
15327
16217
17619
18234
18244
19212
20943
21464
21836
22292
23847
24140
25412
27162
27692
30075
32753
33232
35108
35629
35995
38608
39475
40188
40294
40988
41281
41464
41849
4...

output:

1245648

result:

ok single line: '1245648'

Test #305:

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

input:

1000000 100 50 1000
4919
6240
8211
8257
9364
12447
13429
13497
15222
15796
16384
17405
17565
17645
19549
20799
22133
26147
26661
26693
27934
30937
33712
34681
34952
35577
38573
40010
40582
40760
41303
41342
41578
46052
48398
49197
49253
49514
49556
51014
51217
51777
53168
53734
53856
55366
56381
578...

output:

1486984

result:

ok single line: '1486984'

Test #306:

score: 35
Accepted
time: 17ms
memory: 8552kb

input:

7500099 100 100 100000
99
197
294
390
485
579
672
764
855
945
1034
1122
1209
1295
1380
1464
1547
1629
1710
1790
1869
1947
2024
2100
2175
2249
2322
2394
2465
2535
2604
2672
2739
2805
2870
2934
2997
3059
3120
3180
3239
3297
3354
3410
3465
3519
3572
3624
3675
3725
3776
3828
3881
3935
3990
4046
4103
416...

output:

10000099

result:

ok single line: '10000099'

Test #307:

score: 35
Accepted
time: 12ms
memory: 10596kb

input:

7500099 100 101 100000
99
197
294
390
485
579
672
764
855
945
1034
1122
1209
1295
1380
1464
1547
1629
1710
1790
1869
1947
2024
2100
2175
2249
2322
2394
2465
2535
2604
2672
2739
2805
2870
2934
2997
3059
3120
3180
3239
3297
3354
3410
3465
3519
3572
3624
3675
3725
3776
3828
3881
3935
3990
4046
4103
416...

output:

10000099

result:

ok single line: '10000099'

Test #308:

score: 35
Accepted
time: 63ms
memory: 10196kb

input:

10000000 65536 20 100000
2
49
90
204
316
400
417
962
992
1071
1092
1259
1352
1465
1546
1557
1635
1762
1812
1920
1941
2126
2250
2267
2328
2614
2636
2713
2744
2828
3265
3442
3473
3810
3859
4136
4323
4368
4465
4791
4909
4992
5030
5144
5247
5295
5543
5742
5750
5895
5983
6090
6325
6349
6510
6682
6756
679...

output:

10002557

result:

ok single line: '10002557'

Test #309:

score: 35
Accepted
time: 70ms
memory: 9560kb

input:

100000000 11231 10 99998
3712
3734
4004
5006
5326
5737
6374
7396
7524
9411
9488
9704
9752
11282
13125
13309
13510
14058
16012
16252
16401
17568
18080
18871
20209
20689
22210
22886
29475
30553
31624
33788
35790
36776
37006
38568
38763
41498
42552
42675
43924
46800
48435
48896
49211
49558
49988
50197
...

output:

100088159

result:

ok single line: '100088159'

Test #310:

score: 35
Accepted
time: 84ms
memory: 12848kb

input:

10000000000 1000000 42 98976
3443
82132
378686
611476
1054683
1064922
1085635
1432789
1456397
1605069
1706105
1747555
1805200
1875401
1935898
1946993
2078272
2176040
2207308
2434612
2579296
2674287
2700895
2739654
2803327
2835528
2858398
2860847
2902794
2906251
2912303
2932643
3084465
3104329
310980...

output:

10000419872

result:

ok single line: '10000419872'

Test #311:

score: 35
Accepted
time: 79ms
memory: 12776kb

input:

1000000000 987654 100 98765
13486
20160
26151
38156
51526
51756
95681
102411
119770
124523
131589
136034
137714
149955
150245
156536
171435
197851
213671
244797
251772
253269
261046
263700
265617
270461
272937
274505
293874
303492
316241
321184
323982
324337
335752
341096
383147
403900
411113
419621...

output:

1000100386

result:

ok single line: '1000100386'

Test #312:

score: 35
Accepted
time: 73ms
memory: 11276kb

input:

100000000 123456 2 99999
302
815
848
1134
2206
2426
2987
5049
5755
7477
9115
10198
13547
15493
16223
16308
16858
17448
18020
18221
18280
19140
19535
19747
20468
23610
23892
25078
25141
26173
27270
28101
29052
31441
32381
32471
34435
34494
34803
35550
35818
37695
38849
39839
40543
41254
41843
42126
4...

output:

100001616

result:

ok single line: '100001616'

Test #313:

score: 35
Accepted
time: 70ms
memory: 9336kb

input:

100000000 12345 5123 100000
504
1874
8102
9517
9897
10686
12211
13012
15351
15385
17263
19333
19912
20552
23289
24283
25427
26148
26491
26854
27180
27483
27850
27923
28083
28417
28771
28848
30434
32505
33809
35776
37889
38166
38302
38303
38419
38494
41685
42407
42739
44386
45013
45157
45769
46002
46...

output:

107564626

result:

ok single line: '107564626'

Test #314:

score: 35
Accepted
time: 85ms
memory: 16376kb

input:

1000000000 1000000 30 100000
26833
37697
38884
39990
54007
60455
68746
81856
86315
96832
99439
107172
114710
123585
126120
138636
156954
180677
188565
201451
207981
219500
223059
232305
236227
246939
250956
296338
313925
350134
358621
393892
396448
407580
407605
438955
442240
470942
475605
477483
48...

output:

1000029970

result:

ok single line: '1000029970'

Test #315:

score: 35
Accepted
time: 80ms
memory: 16340kb

input:

1000000000 1000000 56 100000
3208
18055
19548
21511
40299
53599
67672
81450
87674
94520
123335
125124
157703
157932
160356
166035
166878
172438
183823
197558
201516
215801
226144
241444
261772
271507
281156
286846
304313
318109
326378
381833
383243
386666
390611
410798
415599
430543
432253
433373
44...

output:

1000055891

result:

ok single line: '1000055891'

Test #316:

score: 35
Accepted
time: 81ms
memory: 16380kb

input:

1000000000 1000000 72 100000
42374
47451
53192
54218
104451
112483
121875
123673
134194
153967
171124
190686
201787
202793
206578
236016
240793
244789
251122
253490
254239
286728
298512
311442
312596
314606
324479
327502
344053
362675
370468
373738
392852
395877
397686
400370
403103
421137
421972
42...

output:

1000071499

result:

ok single line: '1000071499'

Test #317:

score: 35
Accepted
time: 73ms
memory: 10612kb

input:

3750049999 50000 50000 100000
49999
99997
149994
199990
249985
299979
349972
399964
449955
499945
549934
599922
649909
699895
749880
799864
849847
899829
949810
999790
1049769
1099747
1149724
1199700
1249675
1299649
1349622
1399594
1449565
1499535
1549504
1599472
1649439
1699405
1749370
1799334
1849...

output:

5000049999

result:

ok single line: '5000049999'

Test #318:

score: 35
Accepted
time: 73ms
memory: 8568kb

input:

3750049999 50000 50001 100000
49999
99997
149994
199990
249985
299979
349972
399964
449955
499945
549934
599922
649909
699895
749880
799864
849847
899829
949810
999790
1049769
1099747
1149724
1199700
1249675
1299649
1349622
1399594
1449565
1499535
1549504
1599472
1649439
1699405
1749370
1799334
1849...

output:

5000049999

result:

ok single line: '5000049999'

Test #319:

score: 35
Accepted
time: 1ms
memory: 5600kb

input:

18 4 5 2
8
15

output:

29

result:

ok single line: '29'

Test #320:

score: 35
Accepted
time: 1ms
memory: 5724kb

input:

18 4 0 2
8
15

output:

18

result:

ok single line: '18'

Test #321:

score: 35
Accepted
time: 1ms
memory: 5676kb

input:

18 10 100 2
8
15

output:

20

result:

ok single line: '20'

Test #322:

score: 35
Accepted
time: 1ms
memory: 5728kb

input:

18 4 100 0

output:

418

result:

ok single line: '418'

Test #323:

score: 35
Accepted
time: 1ms
memory: 5664kb

input:

65 20 100 3
14
25
33

output:

172

result:

ok single line: '172'

Subtask #7:

score: 10
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Test #324:

score: 10
Accepted
time: 1ms
memory: 5728kb

input:

1000000000000 1 1000000 0

output:

1000000999999000000

result:

ok single line: '1000000999999000000'

Test #325:

score: 10
Accepted
time: 0ms
memory: 5600kb

input:

100 10 11 10
10
11
20
30
38
49
50
60
70
90

output:

122

result:

ok single line: '122'

Test #326:

score: 10
Accepted
time: 1ms
memory: 5632kb

input:

100 10 11 15
1
5
9
15
24
25
39
40
45
66
75
79
85
95
97

output:

138

result:

ok single line: '138'

Test #327:

score: 10
Accepted
time: 0ms
memory: 5732kb

input:

100000 1000 123 1000
20
25
139
161
312
336
379
472
780
803
1000
1117
1132
1159
1411
1429
1430
1623
1964
2000
2266
2284
2537
2717
2963
3000
3153
3217
3400
3462
3477
3525
3542
3711
3754
3946
3958
4000
4091
4102
4131
4458
4649
4661
4804
4883
4898
4913
4979
5000
5210
5243
5357
5383
5393
5441
5627
5969
6...

output:

100984

result:

ok single line: '100984'

Test #328:

score: 10
Accepted
time: 0ms
memory: 5628kb

input:

100000 100 123 1000
409
858
938
958
1058
1125
1148
1158
1175
1258
1307
1310
1358
1458
1597
1658
1743
1758
1858
2058
2092
2258
2343
2358
2444
2458
2558
2658
2690
2758
2806
2845
2958
3058
3091
3151
3258
3358
3474
3558
3658
3758
3992
4158
4258
4358
4458
4718
5039
5058
5227
5458
5758
5797
5858
5928
5958...

output:

153301

result:

ok single line: '153301'

Test #329:

score: 10
Accepted
time: 14ms
memory: 6768kb

input:

1000000000000 1000000 12345 100000
14000000
22000000
24000000
32000000
44000000
56000000
74000000
87000000
98000000
106000000
126000000
132000000
146000000
171000000
174000000
177000000
195000000
208000000
223000000
224000000
230000000
232000000
246000000
257000000
279000000
282000000
283000000
3200...

output:

1011111722155

result:

ok single line: '1011111722155'

Test #330:

score: 10
Accepted
time: 29ms
memory: 10860kb

input:

1000000000000 1000000 12345 100000
95
241
461
643
755
955
957
1000
1003
1154
1414
1555
1584
1626
1951
2018
2105
2121
2249
2253
2281
2405
2438
2472
2562
2815
2863
2892
2972
3070
3298
3352
3414
3537
3581
3664
3717
4092
4096
4101
4324
4572
4645
4758
4874
4905
4927
4981
5238
5372
5426
5545
5733
5778
604...

output:

1011233973415

result:

ok single line: '1011233973415'

Test #331:

score: 10
Accepted
time: 1ms
memory: 5612kb

input:

108 100 10000 5
10
20
30
40
98

output:

110

result:

ok single line: '110'

Test #332:

score: 10
Accepted
time: 1ms
memory: 5624kb

input:

118 100 10000 5
10
20
30
98
108

output:

120

result:

ok single line: '120'

Test #333:

score: 10
Accepted
time: 1ms
memory: 5664kb

input:

206 100 10000 5
10
20
30
98
196

output:

210

result:

ok single line: '210'

Test #334:

score: 10
Accepted
time: 1ms
memory: 5732kb

input:

128 100 10000 5
10
20
98
108
118

output:

130

result:

ok single line: '130'

Test #335:

score: 10
Accepted
time: 1ms
memory: 5660kb

input:

206 100 10000 5
10
20
98
108
196

output:

210

result:

ok single line: '210'

Test #336:

score: 10
Accepted
time: 1ms
memory: 5724kb

input:

216 100 10000 5
10
20
98
196
206

output:

220

result:

ok single line: '220'

Test #337:

score: 10
Accepted
time: 1ms
memory: 5668kb

input:

304 100 10000 5
10
20
98
196
294

output:

310

result:

ok single line: '310'

Test #338:

score: 10
Accepted
time: 1ms
memory: 5604kb

input:

138 100 10000 5
10
98
108
118
128

output:

140

result:

ok single line: '140'

Test #339:

score: 10
Accepted
time: 0ms
memory: 5660kb

input:

206 100 10000 5
10
98
108
118
196

output:

210

result:

ok single line: '210'

Test #340:

score: 10
Accepted
time: 1ms
memory: 5656kb

input:

216 100 10000 5
10
98
108
196
206

output:

220

result:

ok single line: '220'

Test #341:

score: 10
Accepted
time: 0ms
memory: 5660kb

input:

304 100 10000 5
10
98
108
196
294

output:

310

result:

ok single line: '310'

Test #342:

score: 10
Accepted
time: 1ms
memory: 5596kb

input:

226 100 10000 5
10
98
196
206
216

output:

230

result:

ok single line: '230'

Test #343:

score: 10
Accepted
time: 1ms
memory: 5644kb

input:

304 100 10000 5
10
98
196
206
294

output:

310

result:

ok single line: '310'

Test #344:

score: 10
Accepted
time: 1ms
memory: 5728kb

input:

314 100 10000 5
10
98
196
294
304

output:

320

result:

ok single line: '320'

Test #345:

score: 10
Accepted
time: 1ms
memory: 5664kb

input:

402 100 10000 5
10
98
196
294
392

output:

410

result:

ok single line: '410'

Test #346:

score: 10
Accepted
time: 1ms
memory: 5660kb

input:

148 100 10000 5
98
108
118
128
138

output:

150

result:

ok single line: '150'

Test #347:

score: 10
Accepted
time: 1ms
memory: 5596kb

input:

206 100 10000 5
98
108
118
128
196

output:

210

result:

ok single line: '210'

Test #348:

score: 10
Accepted
time: 0ms
memory: 5680kb

input:

216 100 10000 5
98
108
118
196
206

output:

220

result:

ok single line: '220'

Test #349:

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

input:

304 100 10000 5
98
108
118
196
294

output:

310

result:

ok single line: '310'

Test #350:

score: 10
Accepted
time: 0ms
memory: 5660kb

input:

226 100 10000 5
98
108
196
206
216

output:

230

result:

ok single line: '230'

Test #351:

score: 10
Accepted
time: 0ms
memory: 5656kb

input:

304 100 10000 5
98
108
196
206
294

output:

310

result:

ok single line: '310'

Test #352:

score: 10
Accepted
time: 0ms
memory: 5664kb

input:

314 100 10000 5
98
108
196
294
304

output:

320

result:

ok single line: '320'

Test #353:

score: 10
Accepted
time: 1ms
memory: 5604kb

input:

402 100 10000 5
98
108
196
294
392

output:

410

result:

ok single line: '410'

Test #354:

score: 10
Accepted
time: 0ms
memory: 5676kb

input:

236 100 10000 5
98
196
206
216
226

output:

240

result:

ok single line: '240'

Test #355:

score: 10
Accepted
time: 0ms
memory: 5664kb

input:

304 100 10000 5
98
196
206
216
294

output:

310

result:

ok single line: '310'

Test #356:

score: 10
Accepted
time: 1ms
memory: 5664kb

input:

314 100 10000 5
98
196
206
294
304

output:

320

result:

ok single line: '320'

Test #357:

score: 10
Accepted
time: 0ms
memory: 5596kb

input:

402 100 10000 5
98
196
206
294
392

output:

410

result:

ok single line: '410'

Test #358:

score: 10
Accepted
time: 1ms
memory: 5660kb

input:

324 100 10000 5
98
196
294
304
314

output:

330

result:

ok single line: '330'

Test #359:

score: 10
Accepted
time: 1ms
memory: 5668kb

input:

402 100 10000 5
98
196
294
304
392

output:

410

result:

ok single line: '410'

Test #360:

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

input:

412 100 10000 5
98
196
294
392
402

output:

420

result:

ok single line: '420'

Test #361:

score: 10
Accepted
time: 0ms
memory: 5672kb

input:

500 100 10000 5
98
196
294
392
490

output:

510

result:

ok single line: '510'

Test #362:

score: 10
Accepted
time: 0ms
memory: 5736kb

input:

10 2 10 2
1
3

output:

41

result:

ok single line: '41'

Test #363:

score: 10
Accepted
time: 0ms
memory: 5636kb

input:

100 21 10 2
5
54

output:

140

result:

ok single line: '140'

Test #364:

score: 10
Accepted
time: 1ms
memory: 5736kb

input:

100 21 10 9
18
21
53
62
85
86
88
90
91

output:

121

result:

ok single line: '121'

Test #365:

score: 10
Accepted
time: 0ms
memory: 5632kb

input:

100 21 10 10
30
39
40
43
45
49
52
57
70
72

output:

132

result:

ok single line: '132'

Test #366:

score: 10
Accepted
time: 1ms
memory: 5664kb

input:

156 20 1 10
19
37
54
70
85
99
112
124
135
145

output:

162

result:

ok single line: '162'

Test #367:

score: 10
Accepted
time: 1ms
memory: 5660kb

input:

156 20 20 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #368:

score: 10
Accepted
time: 1ms
memory: 5600kb

input:

156 20 30 10
19
37
54
70
85
99
112
124
135
145

output:

211

result:

ok single line: '211'

Test #369:

score: 10
Accepted
time: 0ms
memory: 5628kb

input:

10 2 10 0

output:

50

result:

ok single line: '50'

Test #370:

score: 10
Accepted
time: 1ms
memory: 5632kb

input:

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

output:

10

result:

ok single line: '10'

Test #371:

score: 10
Accepted
time: 0ms
memory: 5604kb

input:

10 2 10 3
2
4
6

output:

20

result:

ok single line: '20'

Test #372:

score: 10
Accepted
time: 1ms
memory: 5728kb

input:

100 2 10 33
2
5
6
9
10
12
18
26
29
30
32
34
35
42
49
50
52
53
55
56
58
61
62
63
69
71
73
74
82
89
91
93
94

output:

356

result:

ok single line: '356'

Test #373:

score: 10
Accepted
time: 0ms
memory: 5600kb

input:

100 2 10 50
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

output:

340

result:

ok single line: '340'

Test #374:

score: 10
Accepted
time: 1ms
memory: 5664kb

input:

100 2 10 50
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

output:

340

result:

ok single line: '340'

Test #375:

score: 10
Accepted
time: 1ms
memory: 5604kb

input:

100 2 10 50
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
61
63
65
67
69
71
73
75
77
79
81
83
85
87
89
91
93
95
97
99

output:

101

result:

ok single line: '101'

Test #376:

score: 10
Accepted
time: 1ms
memory: 5692kb

input:

1000 2 10 999
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:

1000

result:

ok single line: '1000'

Test #377:

score: 10
Accepted
time: 1ms
memory: 5668kb

input:

1000 42 15 100
9
10
31
35
39
42
53
68
75
77
78
92
117
121
123
141
146
147
157
166
167
193
221
222
231
247
255
265
275
292
305
313
341
343
344
352
357
364
371
380
388
392
410
417
418
445
450
451
452
460
476
479
485
498
501
505
515
524
532
539
542
565
569
570
580
581
585
593
607
618
633
634
642
661
66...

output:

1126

result:

ok single line: '1126'

Test #378:

score: 10
Accepted
time: 1ms
memory: 5604kb

input:

1000 42 14 100
8
15
24
35
46
60
71
98
102
113
125
126
159
164
181
183
191
199
208
212
216
217
240
244
264
265
269
275
295
299
308
309
320
321
342
351
389
404
449
468
476
487
502
520
544
556
563
578
580
581
589
593
598
609
610
623
626
631
650
663
668
669
670
679
695
714
740
741
748
759
774
775
794
79...

output:

1151

result:

ok single line: '1151'

Test #379:

score: 10
Accepted
time: 1ms
memory: 5608kb

input:

909 12 12 100
11
21
30
38
45
51
58
66
75
85
96
108
119
129
138
146
153
159
166
174
183
193
204
216
227
237
246
254
261
267
274
282
291
301
312
324
335
345
354
362
369
375
382
390
399
409
420
432
443
453
462
470
477
483
490
498
507
517
528
540
551
561
570
578
585
591
598
606
615
625
636
648
659
669
6...

output:

1207

result:

ok single line: '1207'

Test #380:

score: 10
Accepted
time: 1ms
memory: 5636kb

input:

909 12 13 100
11
21
30
38
45
51
58
66
75
85
96
108
119
129
138
146
153
159
166
174
183
193
204
216
227
237
246
254
261
267
274
282
291
301
312
324
335
345
354
362
369
375
382
390
399
409
420
432
443
453
462
470
477
483
490
498
507
517
528
540
551
561
570
578
585
591
598
606
615
625
636
648
659
669
6...

output:

1207

result:

ok single line: '1207'

Test #381:

score: 10
Accepted
time: 1ms
memory: 5604kb

input:

1000 2 10 333
1
11
12
14
18
19
20
21
22
23
25
27
36
41
43
44
50
54
56
61
64
66
67
69
70
73
74
76
81
83
85
92
95
97
99
115
117
125
126
127
128
137
140
145
148
150
153
156
158
161
165
166
168
169
173
178
179
180
184
187
191
192
195
197
198
201
202
204
205
209
212
213
214
215
218
223
226
227
228
231
23...

output:

3734

result:

ok single line: '3734'

Test #382:

score: 10
Accepted
time: 1ms
memory: 5668kb

input:

1000 2 10 333
2
3
5
6
7
9
10
11
14
15
16
18
19
20
21
25
28
32
33
36
37
38
39
42
43
44
45
46
47
48
49
52
54
56
57
58
59
61
62
63
64
65
66
68
72
73
74
75
76
77
79
80
82
83
84
85
86
87
88
91
92
94
95
96
97
98
100
101
102
103
106
107
109
110
112
117
118
120
121
124
126
128
129
130
133
134
135
136
137
14...

output:

3905

result:

ok single line: '3905'

Test #383:

score: 10
Accepted
time: 1ms
memory: 5624kb

input:

10000 1000 10 333
56
112
142
157
258
264
369
456
487
489
490
564
614
644
662
742
743
789
796
868
880
904
909
937
944
1025
1030
1050
1059
1075
1087
1106
1201
1223
1230
1251
1254
1264
1275
1283
1303
1345
1346
1412
1500
1547
1571
1580
1589
1606
1608
1673
1736
1874
1881
1886
1893
1899
1900
1965
1972
200...

output:

10080

result:

ok single line: '10080'

Test #384:

score: 10
Accepted
time: 0ms
memory: 5696kb

input:

10000 5112 10 333
100
109
114
153
179
217
259
308
335
427
605
613
654
690
693
718
748
756
792
802
803
834
902
939
993
1001
1067
1109
1130
1138
1140
1178
1185
1201
1220
1230
1256
1268
1302
1315
1318
1383
1385
1418
1437
1440
1490
1505
1524
1528
1588
1639
1716
1816
1895
1902
1969
1970
1998
2018
2019
21...

output:

10001

result:

ok single line: '10001'

Test #385:

score: 10
Accepted
time: 0ms
memory: 5812kb

input:

10000 5112 10 1000
38
43
86
95
100
109
139
145
162
171
172
233
238
246
250
253
255
272
279
282
301
302
303
317
323
335
345
359
389
395
412
422
426
428
429
430
433
447
462
463
466
487
510
517
524
525
534
553
562
589
595
597
600
604
608
612
614
617
631
633
634
637
650
652
654
661
665
692
703
720
723
7...

output:

10001

result:

ok single line: '10001'

Test #386:

score: 10
Accepted
time: 0ms
memory: 5692kb

input:

1000000 100000 10 1000
224
840
3558
4128
4843
5844
6725
7563
8609
10878
11518
11788
12665
17515
19679
20836
23523
25305
25969
26491
26784
28819
29060
30432
31553
32112
34761
35764
36283
36805
37998
39156
41818
41949
42030
43038
43418
45356
45498
46340
47055
47219
47245
47934
48860
49322
49651
50733
...

output:

1000090

result:

ok single line: '1000090'

Test #387:

score: 10
Accepted
time: 1ms
memory: 5684kb

input:

10000000 654321 10 1000
6994
17949
18560
22403
41203
52063
53122
54283
60440
74643
76906
89564
112801
126774
132985
138499
141721
147238
148151
162195
182328
196952
197300
228573
229302
254747
260542
266140
268993
272972
281824
284863
286848
287601
299086
324301
324347
364128
380064
380224
383010
39...

output:

10000150

result:

ok single line: '10000150'

Test #388:

score: 10
Accepted
time: 1ms
memory: 5752kb

input:

10000000 1000000 10 1000
8493
12143
22571
23844
53097
70069
70148
72263
99066
102909
109735
112082
118795
119991
161476
182047
182786
187171
187248
210425
213592
214748
230448
254567
295858
298656
310292
315378
324690
343069
366615
383635
407333
411398
417302
437047
449394
460060
461452
471160
47575...

output:

10000090

result:

ok single line: '10000090'

Test #389:

score: 10
Accepted
time: 1ms
memory: 5640kb

input:

10000 42 8 100
101
337
363
512
585
700
709
831
896
954
1000
1137
1203
1255
1419
1464
1574
1711
1947
1955
2037
2104
2292
2550
2631
2748
2788
2861
2866
2878
2888
3169
3497
3507
3536
3684
3773
3854
3886
4010
4041
4061
4101
4155
4210
4292
4355
4468
4554
4737
4742
4832
4892
4997
5028
5295
5486
5507
5516
...

output:

11781

result:

ok single line: '11781'

Test #390:

score: 10
Accepted
time: 0ms
memory: 5752kb

input:

10000 42 10 1000
11
19
32
38
65
71
77
78
81
91
119
126
138
146
167
172
183
186
192
199
204
211
215
218
220
221
226
228
299
304
319
323
332
353
368
372
377
402
405
414
416
432
470
504
509
515
554
555
566
571
595
596
605
607
634
637
642
654
655
667
697
711
721
723
724
731
733
744
753
760
783
789
796
8...

output:

11093

result:

ok single line: '11093'

Test #391:

score: 10
Accepted
time: 0ms
memory: 5756kb

input:

10000 42 42 1000
14
26
34
47
53
54
75
82
104
107
114
122
126
144
146
148
172
173
204
232
241
247
277
279
285
290
307
316
319
329
335
343
348
356
369
370
377
382
392
427
434
439
456
492
499
500
520
526
533
536
537
547
548
555
557
561
579
586
596
599
605
619
620
624
633
658
665
668
715
747
754
757
761...

output:

12580

result:

ok single line: '12580'

Test #392:

score: 10
Accepted
time: 1ms
memory: 5688kb

input:

10000 100 50 1000
4
35
40
46
50
54
59
70
81
82
83
84
85
100
115
126
140
143
162
176
185
186
195
211
224
237
246
247
253
255
256
272
279
286
306
315
316
319
325
335
345
351
361
384
389
397
410
413
414
426
431
434
450
455
476
478
479
516
527
531
534
537
561
564
576
594
596
599
601
603
615
621
627
632
...

output:

10889

result:

ok single line: '10889'

Test #393:

score: 10
Accepted
time: 1ms
memory: 5712kb

input:

375499 500 500 1000
499
997
1494
1990
2485
2979
3472
3964
4455
4945
5434
5922
6409
6895
7380
7864
8347
8829
9310
9790
10269
10747
11224
11700
12175
12649
13122
13594
14065
14535
15004
15472
15939
16405
16870
17334
17797
18259
18720
19180
19639
20097
20554
21010
21465
21919
22372
22824
23275
23725
24...

output:

500499

result:

ok single line: '500499'

Test #394:

score: 10
Accepted
time: 1ms
memory: 5652kb

input:

375499 500 501 1000
499
997
1494
1990
2485
2979
3472
3964
4455
4945
5434
5922
6409
6895
7380
7864
8347
8829
9310
9790
10269
10747
11224
11700
12175
12649
13122
13594
14065
14535
15004
15472
15939
16405
16870
17334
17797
18259
18720
19180
19639
20097
20554
21010
21465
21919
22372
22824
23275
23725
24...

output:

500499

result:

ok single line: '500499'

Test #395:

score: 10
Accepted
time: 18ms
memory: 10564kb

input:

1000000 100 10 100000
1
8
9
10
12
16
17
20
21
22
23
24
28
30
31
32
34
37
38
41
48
51
58
59
61
63
66
68
70
73
77
79
80
81
82
85
89
90
91
92
96
97
99
100
101
102
105
109
110
111
112
114
115
117
120
123
126
127
130
134
138
139
141
142
144
145
149
150
158
160
161
162
167
169
170
174
175
178
182
185
187
...

output:

1081682

result:

ok single line: '1081682'

Test #396:

score: 10
Accepted
time: 17ms
memory: 6736kb

input:

1000000 100 10 100000
10
14
18
21
22
27
40
42
50
59
105
114
132
142
151
152
166
190
196
197
202
205
210
222
238
241
259
287
288
293
304
309
321
340
350
368
384
385
417
427
437
491
498
526
530
555
556
570
576
589
600
610
620
635
642
644
666
708
709
710
718
727
730
749
751
763
770
782
811
813
815
816
...

output:

1047315

result:

ok single line: '1047315'

Test #397:

score: 10
Accepted
time: 0ms
memory: 5636kb

input:

1000000 100 8 1000
39
1562
1649
2355
4738
4889
5142
5261
5649
6214
8152
8899
11790
11870
12496
12920
13274
13996
14469
14584
18250
18558
18721
21209
26066
26370
26467
27204
28674
28739
30820
31931
32616
36035
36273
38274
39402
39478
41017
41088
43831
43989
45860
46628
46890
49500
51612
52134
52298
5...

output:

1079383

result:

ok single line: '1079383'

Test #398:

score: 10
Accepted
time: 0ms
memory: 5708kb

input:

1000000 100 25 1000
358
1131
1624
2168
2197
3061
3352
3720
3724
3827
4886
5151
5211
8470
10498
11335
13236
13844
14420
15046
15327
16217
17619
18234
18244
19212
20943
21464
21836
22292
23847
24140
25412
27162
27692
30075
32753
33232
35108
35629
35995
38608
39475
40188
40294
40988
41281
41464
41849
4...

output:

1245648

result:

ok single line: '1245648'

Test #399:

score: 10
Accepted
time: 1ms
memory: 5692kb

input:

1000000 100 50 1000
4919
6240
8211
8257
9364
12447
13429
13497
15222
15796
16384
17405
17565
17645
19549
20799
22133
26147
26661
26693
27934
30937
33712
34681
34952
35577
38573
40010
40582
40760
41303
41342
41578
46052
48398
49197
49253
49514
49556
51014
51217
51777
53168
53734
53856
55366
56381
578...

output:

1486984

result:

ok single line: '1486984'

Test #400:

score: 10
Accepted
time: 13ms
memory: 8508kb

input:

7500099 100 100 100000
99
197
294
390
485
579
672
764
855
945
1034
1122
1209
1295
1380
1464
1547
1629
1710
1790
1869
1947
2024
2100
2175
2249
2322
2394
2465
2535
2604
2672
2739
2805
2870
2934
2997
3059
3120
3180
3239
3297
3354
3410
3465
3519
3572
3624
3675
3725
3776
3828
3881
3935
3990
4046
4103
416...

output:

10000099

result:

ok single line: '10000099'

Test #401:

score: 10
Accepted
time: 13ms
memory: 6740kb

input:

7500099 100 101 100000
99
197
294
390
485
579
672
764
855
945
1034
1122
1209
1295
1380
1464
1547
1629
1710
1790
1869
1947
2024
2100
2175
2249
2322
2394
2465
2535
2604
2672
2739
2805
2870
2934
2997
3059
3120
3180
3239
3297
3354
3410
3465
3519
3572
3624
3675
3725
3776
3828
3881
3935
3990
4046
4103
416...

output:

10000099

result:

ok single line: '10000099'

Test #402:

score: 10
Accepted
time: 67ms
memory: 13736kb

input:

10000000 65536 20 100000
2
49
90
204
316
400
417
962
992
1071
1092
1259
1352
1465
1546
1557
1635
1762
1812
1920
1941
2126
2250
2267
2328
2614
2636
2713
2744
2828
3265
3442
3473
3810
3859
4136
4323
4368
4465
4791
4909
4992
5030
5144
5247
5295
5543
5742
5750
5895
5983
6090
6325
6349
6510
6682
6756
679...

output:

10002557

result:

ok single line: '10002557'

Test #403:

score: 10
Accepted
time: 62ms
memory: 10864kb

input:

100000000 11231 10 99998
3712
3734
4004
5006
5326
5737
6374
7396
7524
9411
9488
9704
9752
11282
13125
13309
13510
14058
16012
16252
16401
17568
18080
18871
20209
20689
22210
22886
29475
30553
31624
33788
35790
36776
37006
38568
38763
41498
42552
42675
43924
46800
48435
48896
49211
49558
49988
50197
...

output:

100088159

result:

ok single line: '100088159'

Test #404:

score: 10
Accepted
time: 87ms
memory: 12744kb

input:

10000000000 1000000 42 98976
3443
82132
378686
611476
1054683
1064922
1085635
1432789
1456397
1605069
1706105
1747555
1805200
1875401
1935898
1946993
2078272
2176040
2207308
2434612
2579296
2674287
2700895
2739654
2803327
2835528
2858398
2860847
2902794
2906251
2912303
2932643
3084465
3104329
310980...

output:

10000419872

result:

ok single line: '10000419872'

Test #405:

score: 10
Accepted
time: 84ms
memory: 14564kb

input:

1000000000 987654 100 98765
13486
20160
26151
38156
51526
51756
95681
102411
119770
124523
131589
136034
137714
149955
150245
156536
171435
197851
213671
244797
251772
253269
261046
263700
265617
270461
272937
274505
293874
303492
316241
321184
323982
324337
335752
341096
383147
403900
411113
419621...

output:

1000100386

result:

ok single line: '1000100386'

Test #406:

score: 10
Accepted
time: 69ms
memory: 13256kb

input:

100000000 123456 2 99999
302
815
848
1134
2206
2426
2987
5049
5755
7477
9115
10198
13547
15493
16223
16308
16858
17448
18020
18221
18280
19140
19535
19747
20468
23610
23892
25078
25141
26173
27270
28101
29052
31441
32381
32471
34435
34494
34803
35550
35818
37695
38849
39839
40543
41254
41843
42126
4...

output:

100001616

result:

ok single line: '100001616'

Test #407:

score: 10
Accepted
time: 66ms
memory: 10836kb

input:

100000000 12345 5123 100000
504
1874
8102
9517
9897
10686
12211
13012
15351
15385
17263
19333
19912
20552
23289
24283
25427
26148
26491
26854
27180
27483
27850
27923
28083
28417
28771
28848
30434
32505
33809
35776
37889
38166
38302
38303
38419
38494
41685
42407
42739
44386
45013
45157
45769
46002
46...

output:

107564626

result:

ok single line: '107564626'

Test #408:

score: 10
Accepted
time: 85ms
memory: 14764kb

input:

1000000000 1000000 30 100000
26833
37697
38884
39990
54007
60455
68746
81856
86315
96832
99439
107172
114710
123585
126120
138636
156954
180677
188565
201451
207981
219500
223059
232305
236227
246939
250956
296338
313925
350134
358621
393892
396448
407580
407605
438955
442240
470942
475605
477483
48...

output:

1000029970

result:

ok single line: '1000029970'

Test #409:

score: 10
Accepted
time: 81ms
memory: 12728kb

input:

1000000000 1000000 56 100000
3208
18055
19548
21511
40299
53599
67672
81450
87674
94520
123335
125124
157703
157932
160356
166035
166878
172438
183823
197558
201516
215801
226144
241444
261772
271507
281156
286846
304313
318109
326378
381833
383243
386666
390611
410798
415599
430543
432253
433373
44...

output:

1000055891

result:

ok single line: '1000055891'

Test #410:

score: 10
Accepted
time: 80ms
memory: 14788kb

input:

1000000000 1000000 72 100000
42374
47451
53192
54218
104451
112483
121875
123673
134194
153967
171124
190686
201787
202793
206578
236016
240793
244789
251122
253490
254239
286728
298512
311442
312596
314606
324479
327502
344053
362675
370468
373738
392852
395877
397686
400370
403103
421137
421972
42...

output:

1000071499

result:

ok single line: '1000071499'

Test #411:

score: 10
Accepted
time: 77ms
memory: 8608kb

input:

3750049999 50000 50000 100000
49999
99997
149994
199990
249985
299979
349972
399964
449955
499945
549934
599922
649909
699895
749880
799864
849847
899829
949810
999790
1049769
1099747
1149724
1199700
1249675
1299649
1349622
1399594
1449565
1499535
1549504
1599472
1649439
1699405
1749370
1799334
1849...

output:

5000049999

result:

ok single line: '5000049999'

Test #412:

score: 10
Accepted
time: 77ms
memory: 11864kb

input:

3750049999 50000 50001 100000
49999
99997
149994
199990
249985
299979
349972
399964
449955
499945
549934
599922
649909
699895
749880
799864
849847
899829
949810
999790
1049769
1099747
1149724
1199700
1249675
1299649
1349622
1399594
1449565
1499535
1549504
1599472
1649439
1699405
1749370
1799334
1849...

output:

5000049999

result:

ok single line: '5000049999'

Test #413:

score: 10
Accepted
time: 69ms
memory: 15040kb

input:

100000000000 3000000000 20 100000
67475
1772415
2779164
2989744
3690988
5452794
9422293
9732786
11888720
15213000
15264400
15556992
16253145
16836109
17604137
20736795
21732454
22055688
23721426
24718719
26736138
27166626
27894847
29681792
30878301
32052774
32460091
32761090
32969820
33564063
336989...

output:

100000000660

result:

ok single line: '100000000660'

Test #414:

score: 10
Accepted
time: 71ms
memory: 12988kb

input:

1000000000 12345678 10 99998
19767
25064
28292
31108
31484
37096
52455
53985
74202
101633
113791
124984
126459
141235
155543
164880
192648
192930
198784
210456
211184
212235
218054
225408
250449
256817
259317
262861
266089
273004
273318
274425
274725
279959
281746
295723
301568
308902
316345
330379
...

output:

1000000810

result:

ok single line: '1000000810'

Test #415:

score: 10
Accepted
time: 66ms
memory: 15092kb

input:

10000000000 1001234145 42 98976
98516
110889
227362
416537
416941
492714
576564
724134
1102500
1154438
1227238
1346678
1364807
1400387
1437043
1669696
1692641
1788788
1902128
1965010
2167594
2293626
2314391
2319978
2553700
2602326
2638207
2656114
2672265
2769089
2908767
2924923
3052380
3116107
31919...

output:

10000000378

result:

ok single line: '10000000378'

Test #416:

score: 10
Accepted
time: 59ms
memory: 15032kb

input:

1000000000 98765432 100 98765
563
1485
11019
16360
20911
26616
30262
37972
65808
83365
112377
122167
122919
141242
143552
150900
158056
162062
177192
177756
180813
197652
198787
211559
215408
217415
224801
253291
287247
297275
311630
314075
316735
333302
349356
365849
371810
377766
381586
391842
404...

output:

1000001000

result:

ok single line: '1000001000'

Test #417:

score: 10
Accepted
time: 79ms
memory: 13044kb

input:

1000000000000 3000000000 20 100000
2383804
10661120
22114689
39604034
50306471
52567336
60436681
73472036
79832023
95353240
96656282
98646960
114104395
130951548
132498961
134599007
150690448
159502430
181243690
190876570
190976828
200253267
215798913
216430457
225049460
267480481
268843005
27432600...

output:

1000000006660

result:

ok single line: '1000000006660'

Test #418:

score: 10
Accepted
time: 88ms
memory: 14768kb

input:

1000000000000 12345678 10 99998
8015335
18512101
28113034
33583842
38090533
68521190
73609596
85800485
104974920
116077544
135320254
147008976
152276851
162111272
164660620
189236477
191195714
213605519
213808702
226761506
228774884
276403037
284276903
285537727
287397575
306801888
352275553
3562544...

output:

1000000810000

result:

ok single line: '1000000810000'

Test #419:

score: 10
Accepted
time: 78ms
memory: 14820kb

input:

1000000000000 1001234145 42 98976
7481365
7514623
15564156
30071947
41367246
67989261
84929437
86030479
107006555
108807279
154376907
164272928
169068028
176628424
180478577
181322715
183031112
204187553
225296841
225377627
226941054
239796286
249637632
253671856
255876997
259826979
263084894
263961...

output:

1000000041916

result:

ok single line: '1000000041916'

Test #420:

score: 10
Accepted
time: 89ms
memory: 16524kb

input:

1000000000000 98765432 100 98765
4402616
26606298
30644732
59071383
59854744
61451234
74452478
94560895
94600557
102505281
114544454
146898922
149822666
165387416
180416382
196635170
226805645
229813836
238494645
244387889
276795706
276798271
298570189
302133581
337894094
351058086
367421977
3878054...

output:

1000001012500

result:

ok single line: '1000001012500'

Test #421:

score: 10
Accepted
time: 1ms
memory: 5664kb

input:

18 4 5 2
8
15

output:

29

result:

ok single line: '29'

Test #422:

score: 10
Accepted
time: 1ms
memory: 5732kb

input:

18 4 0 2
8
15

output:

18

result:

ok single line: '18'

Test #423:

score: 10
Accepted
time: 1ms
memory: 5736kb

input:

18 10 100 2
8
15

output:

20

result:

ok single line: '20'

Test #424:

score: 10
Accepted
time: 1ms
memory: 5660kb

input:

18 4 100 0

output:

418

result:

ok single line: '418'

Test #425:

score: 10
Accepted
time: 1ms
memory: 5664kb

input:

65 20 100 3
14
25
33

output:

172

result:

ok single line: '172'