QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296649#6625. BinariaMax_s_xaM25 ✓17ms28460kbC++143.7kb2024-01-03 12:23:372024-01-03 12:23:38

Judging History

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

  • [2024-01-03 12:23:38]
  • 评测
  • 测评结果:25
  • 用时:17ms
  • 内存:28460kb
  • [2024-01-03 12:23:37]
  • 提交

answer

#include <iostream>
#include <algorithm>

typedef long long ll;
typedef double lf;

// #define DEBUG 1
struct IO
{
    #define MAXSIZE (1 << 20)
    #define isdigit(x) (x >= '0' && x <= '9')
    char buf[MAXSIZE], *p1, *p2;
    char pbuf[MAXSIZE], *pp;
    #if DEBUG
    #else
    IO() : p1(buf), p2(buf), pp(pbuf) {}
    ~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);}
    #endif
    #define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) ? ' ' : *p1++)
    #define blank(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t')

    template <typename T>
    void Read(T &x)
    {
        #if DEBUG
        std::cin >> x;
        #else
        bool sign = 0; char ch = gc(); x = 0;
        for (; !isdigit(ch); ch = gc())
            if (ch == '-') sign = 1;
        for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48);
        if (sign) x = -x;
        #endif
    }
    void Read(char *s)
    {
        #if DEBUG
        std::cin >> s;
        #else
        char ch = gc();
        for (; blank(ch); ch = gc());
        for (; !blank(ch); ch = gc()) *s++ = ch;
        *s = 0;
        #endif
    }
    void Read(char &c) {for (c = gc(); blank(c); c = gc());}

    void Push(const char &c)
    {
        #if DEBUG
        putchar(c);
        #else
        if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
        *pp++ = c;
        #endif
    }
    template <typename T>
    void Write(T x)
    {
        if (x < 0) x = -x, Push('-');
        static T sta[35];
        int top = 0;
        do sta[top++] = x % 10, x /= 10; while (x);
        while (top) Push(sta[--top] ^ 48);
    }
    template <typename T>
    void Write(T x, char lst) {Write(x), Push(lst);}
} IO;
#define Read(x) IO.Read(x)
#define Write(x, y) IO.Write(x, y)
#define Put(x) IO.Push(x)

using namespace std;

const int MAXN = 1e6 + 10, mod = 1e6 + 3;

int n, k, a[MAXN];

inline ll Qpow(ll x, int y)
{
    ll res = 1;
    while (y)
    {
        if (y & 1) res = res * x % mod;
        x = x * x % mod, y >>= 1;
    }
    return res;
}
inline ll C(int n, int m)
{
    ll res = 1, dv = 1;
    for (int i = n; i >= n - m + 1; i--) res = res * i % mod;
    for (int i = 2; i <= m; i++) dv = dv * i % mod;
    return res * Qpow(dv, mod - 2) % mod;
}

int fa[MAXN], col[MAXN];
int Find(int k) {return k == fa[k] ? k : fa[k] = Find(fa[k]);}
inline bool Union(int u, int v)
{
    u = Find(u), v = Find(v);
    if (u == v) return 1;
    if (~col[u] && ~col[v] && col[u] != col[v]) return 0;
    if (~col[u]) col[v] = col[u]; else col[u] = col[v];
    fa[u] = v;
    return 1;
}

int main()
{
    #if DEBUG
    #else
    ios::sync_with_stdio(0), cin.tie(0);
    #endif
    Read(n), Read(k);
    for (int i = 1; i <= n - k + 1; i++) Read(a[i]);
    for (int i = 1; i <= n; i++) fa[i] = i, col[i] = -1;
    bool flag = 1;
    for (int i = 1; i < n - k + 1; i++)
    {
        if (a[i] == a[i + 1] + 1)
        {
            if (col[Find(i)] == 0 || col[Find(i + k)] == 1) {flag = 0; break;}
            col[Find(i)] = 1, col[Find(i + k)] = 0;
        }
        else if (a[i] == a[i + 1] - 1)
        {
            if (col[Find(i)] == 1 || col[Find(i + k)] == 0) {flag = 0; break;}
            col[Find(i)] = 0, col[Find(i + k)] = 1;
        }
        else if (a[i] != a[i + 1]) {flag = 0; break;}
        else if (!Union(i, i + k)) {flag = 0; break;}
    }
    if (!flag) return Write(0, '\n'), 0;
    int sum = 0, cnt = 0;
    for (int i = 1; i <= k; i++)
        if (col[Find(i)] == 1) sum++;
        else if (col[Find(i)] == -1) cnt++;
    if (sum > a[1] || sum + cnt < a[1]) return Write(0, '\n'), 0;
    Write(C(cnt, a[1] - sum), '\n');
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 2ms
memory: 9732kb

input:

1 1
0

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

1 1
1

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

10 3
1 2 2 2 2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

10 3
1 1 0 1 2 3 2 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

10 3
2 2 2 2 2 2 2 2

output:

3

result:

ok 1 number(s): "3"

Test #6:

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

input:

10 3
2 1 1 1 1 2 2 3

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

input:

10 3
1 1 1 0 0 0 0 0

output:

1

result:

ok 1 number(s): "1"

Test #8:

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

input:

10 3
0 0 0 0 0 0 0 0

output:

1

result:

ok 1 number(s): "1"

Test #9:

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

input:

10 2
1 1 1 1 1 1 1 1 1

output:

2

result:

ok 1 number(s): "2"

Test #10:

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

input:

10 2
1 1 1 1 1 1 1 1 2

output:

1

result:

ok 1 number(s): "1"

Test #11:

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

input:

10 2
1 1 0 0 0 0 0 1 2

output:

1

result:

ok 1 number(s): "1"

Test #12:

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

input:

2 2
1

output:

2

result:

ok 1 number(s): "2"

Subtask #2:

score: 3
Accepted

Dependency #1:

100%
Accepted

Test #13:

score: 3
Accepted
time: 1ms
memory: 9880kb

input:

10 10
7

output:

120

result:

ok 1 number(s): "120"

Test #14:

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

input:

10 10
1

output:

10

result:

ok 1 number(s): "10"

Test #15:

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

input:

10 5
3 4 3 2 3 2

output:

1

result:

ok 1 number(s): "1"

Test #16:

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

input:

10 6
3 3 3 3 4

output:

10

result:

ok 1 number(s): "10"

Test #17:

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

input:

10 4
2 2 2 1 1 1 1

output:

3

result:

ok 1 number(s): "3"

Test #18:

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

input:

10 7
1 2 3 2

output:

1

result:

ok 1 number(s): "1"

Test #19:

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

input:

10 8
8 8 7

output:

1

result:

ok 1 number(s): "1"

Test #20:

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

input:

10 9
4 5

output:

70

result:

ok 1 number(s): "70"

Subtask #3:

score: 4
Accepted

Dependency #2:

100%
Accepted

Test #21:

score: 4
Accepted
time: 1ms
memory: 9896kb

input:

1000 10
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...

output:

210

result:

ok 1 number(s): "210"

Test #22:

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

input:

1000 10
5 6 6 7 7 7 7 8 7 8 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 6 6 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 6 6 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 6 6 6 6 ...

output:

1

result:

ok 1 number(s): "1"

Test #23:

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

input:

1000 10
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ...

output:

252

result:

ok 1 number(s): "252"

Test #24:

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

input:

1000 10
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 ...

output:

45

result:

ok 1 number(s): "45"

Test #25:

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

input:

1000 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

1

result:

ok 1 number(s): "1"

Test #26:

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

input:

1000 10
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

1

result:

ok 1 number(s): "1"

Test #27:

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

input:

1000 9
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5...

output:

126

result:

ok 1 number(s): "126"

Test #28:

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

input:

1000 9
5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4...

output:

70

result:

ok 1 number(s): "70"

Test #29:

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

input:

1000 9
7 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6...

output:

28

result:

ok 1 number(s): "28"

Test #30:

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

input:

1000 9
6 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6...

output:

10

result:

ok 1 number(s): "10"

Test #31:

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

input:

1000 10
5 5 5 5 4 4 4 4 4 4 3 3 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

15

result:

ok 1 number(s): "15"

Test #32:

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

input:

1000 7
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

15

result:

ok 1 number(s): "15"

Test #33:

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

input:

1000 8
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5...

output:

56

result:

ok 1 number(s): "56"

Subtask #4:

score: 4
Accepted

Dependency #3:

100%
Accepted

Test #34:

score: 4
Accepted
time: 10ms
memory: 17008kb

input:

1000000 20
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9...

output:

167960

result:

ok 1 number(s): "167960"

Test #35:

score: 0
Accepted
time: 14ms
memory: 16972kb

input:

1000000 20
10 10 11 10 10 10 10 10 10 10 9 9 10 9 8 8 8 8 8 9 9 9 9 10 10 10 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 8 9 9 9 9 9 9 9 9 10 10 10 10 10 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 10 10 9 10 10 10 9 9 9 9 9 9 9 9 9 9 10 10 10 10 11 11 11 11 11 11 11 11 11 11 11 11 11 1...

output:

1

result:

ok 1 number(s): "1"

Test #36:

score: 0
Accepted
time: 12ms
memory: 16980kb

input:

1000000 20
14 14 13 13 12 12 13 13 13 14 14 13 12 12 13 13 13 13 12 11 11 11 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 12 11 11 11 11 11 11 11 11 11 11 11 11 11 11 10 10 10 10 10 11 11 11 11 11 11 11 11 11 1...

output:

1

result:

ok 1 number(s): "1"

Test #37:

score: 0
Accepted
time: 14ms
memory: 17332kb

input:

1000000 20
17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 1...

output:

153

result:

ok 1 number(s): "153"

Test #38:

score: 0
Accepted
time: 14ms
memory: 16952kb

input:

1000000 20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

1

result:

ok 1 number(s): "1"

Test #39:

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

input:

1000000 20
20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2...

output:

1

result:

ok 1 number(s): "1"

Test #40:

score: 0
Accepted
time: 9ms
memory: 16992kb

input:

1000000 20
13 13 13 13 13 13 13 12 12 12 12 12 12 13 14 14 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 13 13 12 12 12 12 12 12 12 1...

output:

5

result:

ok 1 number(s): "5"

Test #41:

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

input:

1000000 13
5 5 4 4 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

84

result:

ok 1 number(s): "84"

Test #42:

score: 0
Accepted
time: 9ms
memory: 17048kb

input:

1000000 18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

15

result:

ok 1 number(s): "15"

Test #43:

score: 0
Accepted
time: 11ms
memory: 28460kb

input:

1000000 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1

result:

ok 1 number(s): "1"

Test #44:

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

input:

1000000 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

1

result:

ok 1 number(s): "1"

Test #45:

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

input:

1000000 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

1

result:

ok 1 number(s): "1"

Test #46:

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

input:

1000000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

2

result:

ok 1 number(s): "2"

Test #47:

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

input:

1000000 20
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

184756

result:

ok 1 number(s): "184756"

Test #48:

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

input:

1000000 20
12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 1...

output:

50388

result:

ok 1 number(s): "50388"

Subtask #5:

score: 4
Accepted

Dependency #4:

100%
Accepted

Test #49:

score: 4
Accepted
time: 16ms
memory: 17248kb

input:

1000000 3000
1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 15...

output:

53926

result:

ok 1 number(s): "53926"

Test #50:

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

input:

1000000 3000
1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 19...

output:

375745

result:

ok 1 number(s): "375745"

Test #51:

score: 0
Accepted
time: 12ms
memory: 16408kb

input:

1000000 3000
1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1436 1435 1435 1435 1435 1435 1435 1435 1435 1435 1435 1435 1435 1435 1435 1435 1435 1435 14...

output:

611689

result:

ok 1 number(s): "611689"

Test #52:

score: 0
Accepted
time: 12ms
memory: 17244kb

input:

1000000 3000
1511 1512 1512 1512 1512 1511 1510 1511 1511 1512 1513 1512 1512 1511 1511 1511 1511 1510 1511 1511 1511 1512 1511 1510 1509 1510 1509 1510 1510 1509 1510 1511 1512 1512 1512 1511 1512 1511 1511 1512 1512 1513 1513 1512 1512 1513 1512 1511 1512 1511 1512 1513 1512 1512 1513 1513 1514 15...

output:

1

result:

ok 1 number(s): "1"

Test #53:

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

input:

1000000 3000
2876 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2875 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 2874 28...

output:

1

result:

ok 1 number(s): "1"

Test #54:

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

input:

1000000 3000
2977 2977 2977 2977 2977 2977 2977 2977 2977 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 2978 29...

output:

471615

result:

ok 1 number(s): "471615"

Test #55:

score: 0
Accepted
time: 16ms
memory: 16796kb

input:

1000000 3000
1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 1996 19...

output:

70180

result:

ok 1 number(s): "70180"

Test #56:

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

input:

1000000 3000
867 867 867 867 867 867 867 867 867 868 868 868 868 868 868 868 867 867 867 866 866 866 866 865 866 866 867 867 866 866 867 868 869 869 869 869 868 868 869 870 870 869 869 869 869 869 869 868 868 869 870 869 868 868 868 868 868 867 867 867 868 869 870 870 869 870 870 871 871 872 871 871...

output:

1

result:

ok 1 number(s): "1"

Test #57:

score: 0
Accepted
time: 12ms
memory: 16600kb

input:

1000000 3000
2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 2997 29...

output:

487515

result:

ok 1 number(s): "487515"

Test #58:

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

input:

1000000 3000
2397 2397 2397 2397 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2396 2397 2397 2397 2397 2397 2397 2397 2397 2396 2396 2396 2396 2397 2397 2397 2397 2397 2397 2398 2398 2398 2398 23...

output:

943965

result:

ok 1 number(s): "943965"

Test #59:

score: 0
Accepted
time: 12ms
memory: 16344kb

input:

1000000 1337
478 477 477 477 477 478 478 478 479 480 480 479 478 477 477 477 477 477 478 478 478 479 478 478 477 477 477 477 478 478 479 479 479 479 479 480 479 479 478 479 480 480 480 481 482 482 482 482 482 482 482 481 481 480 480 479 479 480 481 481 481 481 482 482 482 483 483 483 484 484 485 484...

output:

645202

result:

ok 1 number(s): "645202"

Subtask #6:

score: 7
Accepted

Dependency #5:

100%
Accepted

Test #60:

score: 7
Accepted
time: 7ms
memory: 13652kb

input:

1000000 1000000
500000

output:

375001

result:

ok 1 number(s): "375001"

Test #61:

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

input:

1000000 1000000
376577

output:

529387

result:

ok 1 number(s): "529387"

Test #62:

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

input:

1000000 999999
876543 876543

output:

614361

result:

ok 1 number(s): "614361"

Test #63:

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

input:

1000000 999999
553875 553876

output:

277031

result:

ok 1 number(s): "277031"

Test #64:

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

input:

1000000 500000
364645 364645 364645 364645 364645 364645 364645 364644 364644 364644 364644 364644 364644 364644 364643 364643 364643 364643 364643 364643 364643 364643 364643 364643 364643 364643 364642 364642 364642 364642 364642 364642 364642 364642 364642 364642 364642 364642 364642 364642 36464...

output:

48211

result:

ok 1 number(s): "48211"

Test #65:

score: 0
Accepted
time: 11ms
memory: 16464kb

input:

1000000 654321
306156 306156 306156 306156 306156 306156 306156 306156 306156 306156 306156 306157 306157 306157 306157 306157 306157 306157 306157 306157 306158 306158 306158 306158 306158 306158 306158 306158 306157 306157 306157 306157 306157 306157 306157 306157 306157 306157 306157 306157 30615...

output:

149704

result:

ok 1 number(s): "149704"

Test #66:

score: 0
Accepted
time: 11ms
memory: 16392kb

input:

1000000 200000
134176 134176 134177 134177 134178 134178 134177 134178 134178 134178 134178 134177 134177 134178 134179 134179 134179 134179 134179 134179 134179 134179 134179 134179 134178 134179 134179 134179 134179 134178 134178 134178 134178 134177 134177 134177 134177 134177 134176 134176 13417...

output:

814377

result:

ok 1 number(s): "814377"

Test #67:

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

input:

1000000 909090
9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 9045 ...

output:

604727

result:

ok 1 number(s): "604727"

Test #68:

score: 0
Accepted
time: 11ms
memory: 14744kb

input:

1000000 1000000
1000000

output:

1

result:

ok 1 number(s): "1"

Test #69:

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

input:

1000000 1000000
0

output:

1

result:

ok 1 number(s): "1"

Test #70:

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

input:

1000000 999999
499999 500000

output:

507814

result:

ok 1 number(s): "507814"

Extra Test:

score: 0
Extra Test Passed