답안 #1097182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097182 2024-10-06T11:48:38 Z raphaelp Binaria (CCO23_day1problem1) C++14
25 / 25
188 ms 28752 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
long long fac[MAXN + 1];
long long inv[MAXN + 1];
long long exp(long long x, long long n, long long m)
{
    x %= m;
    long long ans = 1;
    while (n > 0)
    {
        if (n % 2)
            ans = (ans * x) % m;
        n /= 2;
        x = (x * x) % m;
    }
    return ans;
}
void precalc(long long p)
{
    fac[0] = 1;
    for (int i = 1; i <= MAXN; i++)
    {
        fac[i] = (fac[i - 1] * i) % p;
    }
    inv[MAXN] = exp(fac[MAXN], p - 2, p);
    for (int i = MAXN; i >= 1; i--)
        inv[i - 1] = (inv[i] * i) % p;
}
long long choose(int n, int k, int p)
{
    return ((fac[n] * inv[k]) % p * inv[n - k]) % p;
}
int main()
{
    precalc(1000003);
    int N, K;
    cin >> N >> K;
    vector<int> Tab(N - K + 1);
    for (int i = 0; i < N - K + 1; i++)
    {
        cin >> Tab[i];
    }
    vector<int> val(N, -1);
    for (int i = 1; i < N - K + 1; i++)
    {
        if (Tab[i] == Tab[i - 1])
            val[i + K - 1] = val[i - 1];
        if (Tab[i] > Tab[i - 1])
            val[i + K - 1] = 1;
        if (Tab[i] < Tab[i - 1])
            val[i + K - 1] = 0;
    }
    int a = Tab.back(), b = K;
    for (int i = N - K; i < N; i++)
    {
        if (val[i] == 1)
        {
            a--;
            b--;
        }
        if (val[i] == 0)
            b--;
    }
    cout << choose(b, a, 1000003);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15960 KB Output is correct
2 Correct 15 ms 16024 KB Output is correct
3 Correct 18 ms 15964 KB Output is correct
4 Correct 16 ms 16068 KB Output is correct
5 Correct 15 ms 16040 KB Output is correct
6 Correct 15 ms 15964 KB Output is correct
7 Correct 15 ms 15960 KB Output is correct
8 Correct 16 ms 15960 KB Output is correct
9 Correct 17 ms 15964 KB Output is correct
10 Correct 16 ms 15964 KB Output is correct
11 Correct 18 ms 15964 KB Output is correct
12 Correct 16 ms 16088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15960 KB Output is correct
2 Correct 15 ms 16024 KB Output is correct
3 Correct 18 ms 15964 KB Output is correct
4 Correct 16 ms 16068 KB Output is correct
5 Correct 15 ms 16040 KB Output is correct
6 Correct 15 ms 15964 KB Output is correct
7 Correct 15 ms 15960 KB Output is correct
8 Correct 16 ms 15960 KB Output is correct
9 Correct 17 ms 15964 KB Output is correct
10 Correct 16 ms 15964 KB Output is correct
11 Correct 18 ms 15964 KB Output is correct
12 Correct 16 ms 16088 KB Output is correct
13 Correct 15 ms 15964 KB Output is correct
14 Correct 15 ms 15856 KB Output is correct
15 Correct 15 ms 15964 KB Output is correct
16 Correct 15 ms 15964 KB Output is correct
17 Correct 16 ms 15988 KB Output is correct
18 Correct 15 ms 16088 KB Output is correct
19 Correct 15 ms 15964 KB Output is correct
20 Correct 17 ms 15856 KB Output is correct
21 Correct 16 ms 15964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15960 KB Output is correct
2 Correct 15 ms 16024 KB Output is correct
3 Correct 18 ms 15964 KB Output is correct
4 Correct 16 ms 16068 KB Output is correct
5 Correct 15 ms 16040 KB Output is correct
6 Correct 15 ms 15964 KB Output is correct
7 Correct 15 ms 15960 KB Output is correct
8 Correct 16 ms 15960 KB Output is correct
9 Correct 17 ms 15964 KB Output is correct
10 Correct 16 ms 15964 KB Output is correct
11 Correct 18 ms 15964 KB Output is correct
12 Correct 16 ms 16088 KB Output is correct
13 Correct 15 ms 15964 KB Output is correct
14 Correct 15 ms 15856 KB Output is correct
15 Correct 15 ms 15964 KB Output is correct
16 Correct 15 ms 15964 KB Output is correct
17 Correct 16 ms 15988 KB Output is correct
18 Correct 15 ms 16088 KB Output is correct
19 Correct 15 ms 15964 KB Output is correct
20 Correct 17 ms 15856 KB Output is correct
21 Correct 16 ms 15964 KB Output is correct
22 Correct 16 ms 15964 KB Output is correct
23 Correct 16 ms 15964 KB Output is correct
24 Correct 15 ms 15960 KB Output is correct
25 Correct 15 ms 16036 KB Output is correct
26 Correct 16 ms 15964 KB Output is correct
27 Correct 17 ms 16096 KB Output is correct
28 Correct 16 ms 15964 KB Output is correct
29 Correct 17 ms 16000 KB Output is correct
30 Correct 15 ms 16096 KB Output is correct
31 Correct 16 ms 15980 KB Output is correct
32 Correct 17 ms 15964 KB Output is correct
33 Correct 15 ms 15964 KB Output is correct
34 Correct 14 ms 15964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15960 KB Output is correct
2 Correct 15 ms 16024 KB Output is correct
3 Correct 18 ms 15964 KB Output is correct
4 Correct 16 ms 16068 KB Output is correct
5 Correct 15 ms 16040 KB Output is correct
6 Correct 15 ms 15964 KB Output is correct
7 Correct 15 ms 15960 KB Output is correct
8 Correct 16 ms 15960 KB Output is correct
9 Correct 17 ms 15964 KB Output is correct
10 Correct 16 ms 15964 KB Output is correct
11 Correct 18 ms 15964 KB Output is correct
12 Correct 16 ms 16088 KB Output is correct
13 Correct 15 ms 15964 KB Output is correct
14 Correct 15 ms 15856 KB Output is correct
15 Correct 15 ms 15964 KB Output is correct
16 Correct 15 ms 15964 KB Output is correct
17 Correct 16 ms 15988 KB Output is correct
18 Correct 15 ms 16088 KB Output is correct
19 Correct 15 ms 15964 KB Output is correct
20 Correct 17 ms 15856 KB Output is correct
21 Correct 16 ms 15964 KB Output is correct
22 Correct 16 ms 15964 KB Output is correct
23 Correct 16 ms 15964 KB Output is correct
24 Correct 15 ms 15960 KB Output is correct
25 Correct 15 ms 16036 KB Output is correct
26 Correct 16 ms 15964 KB Output is correct
27 Correct 17 ms 16096 KB Output is correct
28 Correct 16 ms 15964 KB Output is correct
29 Correct 17 ms 16000 KB Output is correct
30 Correct 15 ms 16096 KB Output is correct
31 Correct 16 ms 15980 KB Output is correct
32 Correct 17 ms 15964 KB Output is correct
33 Correct 15 ms 15964 KB Output is correct
34 Correct 14 ms 15964 KB Output is correct
35 Correct 98 ms 25680 KB Output is correct
36 Correct 110 ms 26376 KB Output is correct
37 Correct 117 ms 26704 KB Output is correct
38 Correct 122 ms 26716 KB Output is correct
39 Correct 103 ms 25684 KB Output is correct
40 Correct 118 ms 26652 KB Output is correct
41 Correct 112 ms 26712 KB Output is correct
42 Correct 104 ms 25680 KB Output is correct
43 Correct 96 ms 25740 KB Output is correct
44 Correct 101 ms 25752 KB Output is correct
45 Correct 102 ms 25684 KB Output is correct
46 Correct 108 ms 25756 KB Output is correct
47 Correct 106 ms 25752 KB Output is correct
48 Correct 124 ms 26640 KB Output is correct
49 Correct 116 ms 26704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15960 KB Output is correct
2 Correct 15 ms 16024 KB Output is correct
3 Correct 18 ms 15964 KB Output is correct
4 Correct 16 ms 16068 KB Output is correct
5 Correct 15 ms 16040 KB Output is correct
6 Correct 15 ms 15964 KB Output is correct
7 Correct 15 ms 15960 KB Output is correct
8 Correct 16 ms 15960 KB Output is correct
9 Correct 17 ms 15964 KB Output is correct
10 Correct 16 ms 15964 KB Output is correct
11 Correct 18 ms 15964 KB Output is correct
12 Correct 16 ms 16088 KB Output is correct
13 Correct 15 ms 15964 KB Output is correct
14 Correct 15 ms 15856 KB Output is correct
15 Correct 15 ms 15964 KB Output is correct
16 Correct 15 ms 15964 KB Output is correct
17 Correct 16 ms 15988 KB Output is correct
18 Correct 15 ms 16088 KB Output is correct
19 Correct 15 ms 15964 KB Output is correct
20 Correct 17 ms 15856 KB Output is correct
21 Correct 16 ms 15964 KB Output is correct
22 Correct 16 ms 15964 KB Output is correct
23 Correct 16 ms 15964 KB Output is correct
24 Correct 15 ms 15960 KB Output is correct
25 Correct 15 ms 16036 KB Output is correct
26 Correct 16 ms 15964 KB Output is correct
27 Correct 17 ms 16096 KB Output is correct
28 Correct 16 ms 15964 KB Output is correct
29 Correct 17 ms 16000 KB Output is correct
30 Correct 15 ms 16096 KB Output is correct
31 Correct 16 ms 15980 KB Output is correct
32 Correct 17 ms 15964 KB Output is correct
33 Correct 15 ms 15964 KB Output is correct
34 Correct 14 ms 15964 KB Output is correct
35 Correct 98 ms 25680 KB Output is correct
36 Correct 110 ms 26376 KB Output is correct
37 Correct 117 ms 26704 KB Output is correct
38 Correct 122 ms 26716 KB Output is correct
39 Correct 103 ms 25684 KB Output is correct
40 Correct 118 ms 26652 KB Output is correct
41 Correct 112 ms 26712 KB Output is correct
42 Correct 104 ms 25680 KB Output is correct
43 Correct 96 ms 25740 KB Output is correct
44 Correct 101 ms 25752 KB Output is correct
45 Correct 102 ms 25684 KB Output is correct
46 Correct 108 ms 25756 KB Output is correct
47 Correct 106 ms 25752 KB Output is correct
48 Correct 124 ms 26640 KB Output is correct
49 Correct 116 ms 26704 KB Output is correct
50 Correct 167 ms 28752 KB Output is correct
51 Correct 187 ms 28544 KB Output is correct
52 Correct 153 ms 28752 KB Output is correct
53 Correct 162 ms 28540 KB Output is correct
54 Correct 176 ms 28700 KB Output is correct
55 Correct 150 ms 28548 KB Output is correct
56 Correct 153 ms 28748 KB Output is correct
57 Correct 142 ms 27892 KB Output is correct
58 Correct 153 ms 28752 KB Output is correct
59 Correct 154 ms 28548 KB Output is correct
60 Correct 139 ms 27796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15960 KB Output is correct
2 Correct 15 ms 16024 KB Output is correct
3 Correct 18 ms 15964 KB Output is correct
4 Correct 16 ms 16068 KB Output is correct
5 Correct 15 ms 16040 KB Output is correct
6 Correct 15 ms 15964 KB Output is correct
7 Correct 15 ms 15960 KB Output is correct
8 Correct 16 ms 15960 KB Output is correct
9 Correct 17 ms 15964 KB Output is correct
10 Correct 16 ms 15964 KB Output is correct
11 Correct 18 ms 15964 KB Output is correct
12 Correct 16 ms 16088 KB Output is correct
13 Correct 15 ms 15964 KB Output is correct
14 Correct 15 ms 15856 KB Output is correct
15 Correct 15 ms 15964 KB Output is correct
16 Correct 15 ms 15964 KB Output is correct
17 Correct 16 ms 15988 KB Output is correct
18 Correct 15 ms 16088 KB Output is correct
19 Correct 15 ms 15964 KB Output is correct
20 Correct 17 ms 15856 KB Output is correct
21 Correct 16 ms 15964 KB Output is correct
22 Correct 16 ms 15964 KB Output is correct
23 Correct 16 ms 15964 KB Output is correct
24 Correct 15 ms 15960 KB Output is correct
25 Correct 15 ms 16036 KB Output is correct
26 Correct 16 ms 15964 KB Output is correct
27 Correct 17 ms 16096 KB Output is correct
28 Correct 16 ms 15964 KB Output is correct
29 Correct 17 ms 16000 KB Output is correct
30 Correct 15 ms 16096 KB Output is correct
31 Correct 16 ms 15980 KB Output is correct
32 Correct 17 ms 15964 KB Output is correct
33 Correct 15 ms 15964 KB Output is correct
34 Correct 14 ms 15964 KB Output is correct
35 Correct 98 ms 25680 KB Output is correct
36 Correct 110 ms 26376 KB Output is correct
37 Correct 117 ms 26704 KB Output is correct
38 Correct 122 ms 26716 KB Output is correct
39 Correct 103 ms 25684 KB Output is correct
40 Correct 118 ms 26652 KB Output is correct
41 Correct 112 ms 26712 KB Output is correct
42 Correct 104 ms 25680 KB Output is correct
43 Correct 96 ms 25740 KB Output is correct
44 Correct 101 ms 25752 KB Output is correct
45 Correct 102 ms 25684 KB Output is correct
46 Correct 108 ms 25756 KB Output is correct
47 Correct 106 ms 25752 KB Output is correct
48 Correct 124 ms 26640 KB Output is correct
49 Correct 116 ms 26704 KB Output is correct
50 Correct 167 ms 28752 KB Output is correct
51 Correct 187 ms 28544 KB Output is correct
52 Correct 153 ms 28752 KB Output is correct
53 Correct 162 ms 28540 KB Output is correct
54 Correct 176 ms 28700 KB Output is correct
55 Correct 150 ms 28548 KB Output is correct
56 Correct 153 ms 28748 KB Output is correct
57 Correct 142 ms 27892 KB Output is correct
58 Correct 153 ms 28752 KB Output is correct
59 Correct 154 ms 28548 KB Output is correct
60 Correct 139 ms 27796 KB Output is correct
61 Correct 18 ms 19796 KB Output is correct
62 Correct 16 ms 19804 KB Output is correct
63 Correct 19 ms 19804 KB Output is correct
64 Correct 19 ms 19804 KB Output is correct
65 Correct 103 ms 25264 KB Output is correct
66 Correct 77 ms 23564 KB Output is correct
67 Correct 188 ms 28424 KB Output is correct
68 Correct 29 ms 20744 KB Output is correct
69 Correct 17 ms 19772 KB Output is correct
70 Correct 17 ms 19804 KB Output is correct
71 Correct 17 ms 19804 KB Output is correct