# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
792414 |
2023-07-25T04:27:15 Z |
박영우(#10055) |
Binaria (CCO23_day1problem1) |
C++17 |
|
74 ms |
12084 KB |
#include <bits/stdc++.h>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 1010101
#define MAXS 500
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 1000003
int A[MAX];
ll fact[MAX];
int chk[MAX];
ll mpow(ll x, ll y = MOD - 2) {
if (!y) return 1;
ll res = mpow(x, y >> 1);
res *= res;
res %= MOD;
if (y & 1) res *= x, res %= MOD;
return res;
}
ll C(ll n, ll r) {
if (r < 0 || r > n) return 0;
if (n < 0) return 0;
ll res = fact[n];
res *= mpow(fact[r]);
res %= MOD;
res *= mpow(fact[n - r]);
res %= MOD;
return res;
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int N, K;
cin >> N >> K;
int i;
fact[0] = 1;
for (i = 1; i <= N; i++) fact[i] = (fact[i - 1] * i) % MOD;
int all = K;
int cnt = 0;
for (i = 0; i < N - K + 1; i++) {
cin >> A[i];
if (i) {
if (chk[(i - 1) % K]) continue;
if (A[i] > A[i - 1]) all--, chk[(i - 1) % K] = 1;
if (A[i] < A[i - 1]) all--, cnt--, chk[(i - 1) % K] = 1;
}
else cnt = A[0];
}
cout << C(all, cnt);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
26 |
Correct |
0 ms |
340 KB |
Output is correct |
27 |
Correct |
0 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
0 ms |
340 KB |
Output is correct |
33 |
Correct |
0 ms |
340 KB |
Output is correct |
34 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
26 |
Correct |
0 ms |
340 KB |
Output is correct |
27 |
Correct |
0 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
0 ms |
340 KB |
Output is correct |
33 |
Correct |
0 ms |
340 KB |
Output is correct |
34 |
Correct |
0 ms |
340 KB |
Output is correct |
35 |
Correct |
56 ms |
12068 KB |
Output is correct |
36 |
Correct |
55 ms |
12024 KB |
Output is correct |
37 |
Correct |
57 ms |
12000 KB |
Output is correct |
38 |
Correct |
53 ms |
12044 KB |
Output is correct |
39 |
Correct |
62 ms |
11972 KB |
Output is correct |
40 |
Correct |
53 ms |
11960 KB |
Output is correct |
41 |
Correct |
57 ms |
11956 KB |
Output is correct |
42 |
Correct |
51 ms |
12048 KB |
Output is correct |
43 |
Correct |
48 ms |
12028 KB |
Output is correct |
44 |
Correct |
47 ms |
12056 KB |
Output is correct |
45 |
Correct |
46 ms |
12020 KB |
Output is correct |
46 |
Correct |
49 ms |
12036 KB |
Output is correct |
47 |
Correct |
47 ms |
11988 KB |
Output is correct |
48 |
Correct |
52 ms |
11956 KB |
Output is correct |
49 |
Correct |
56 ms |
12080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
26 |
Correct |
0 ms |
340 KB |
Output is correct |
27 |
Correct |
0 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
0 ms |
340 KB |
Output is correct |
33 |
Correct |
0 ms |
340 KB |
Output is correct |
34 |
Correct |
0 ms |
340 KB |
Output is correct |
35 |
Correct |
56 ms |
12068 KB |
Output is correct |
36 |
Correct |
55 ms |
12024 KB |
Output is correct |
37 |
Correct |
57 ms |
12000 KB |
Output is correct |
38 |
Correct |
53 ms |
12044 KB |
Output is correct |
39 |
Correct |
62 ms |
11972 KB |
Output is correct |
40 |
Correct |
53 ms |
11960 KB |
Output is correct |
41 |
Correct |
57 ms |
11956 KB |
Output is correct |
42 |
Correct |
51 ms |
12048 KB |
Output is correct |
43 |
Correct |
48 ms |
12028 KB |
Output is correct |
44 |
Correct |
47 ms |
12056 KB |
Output is correct |
45 |
Correct |
46 ms |
12020 KB |
Output is correct |
46 |
Correct |
49 ms |
12036 KB |
Output is correct |
47 |
Correct |
47 ms |
11988 KB |
Output is correct |
48 |
Correct |
52 ms |
11956 KB |
Output is correct |
49 |
Correct |
56 ms |
12080 KB |
Output is correct |
50 |
Correct |
71 ms |
12052 KB |
Output is correct |
51 |
Correct |
61 ms |
11980 KB |
Output is correct |
52 |
Correct |
61 ms |
11980 KB |
Output is correct |
53 |
Correct |
67 ms |
12068 KB |
Output is correct |
54 |
Correct |
61 ms |
11948 KB |
Output is correct |
55 |
Correct |
65 ms |
12004 KB |
Output is correct |
56 |
Correct |
69 ms |
12028 KB |
Output is correct |
57 |
Correct |
61 ms |
12064 KB |
Output is correct |
58 |
Correct |
60 ms |
12048 KB |
Output is correct |
59 |
Correct |
74 ms |
12056 KB |
Output is correct |
60 |
Correct |
62 ms |
12084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
26 |
Correct |
0 ms |
340 KB |
Output is correct |
27 |
Correct |
0 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
0 ms |
340 KB |
Output is correct |
33 |
Correct |
0 ms |
340 KB |
Output is correct |
34 |
Correct |
0 ms |
340 KB |
Output is correct |
35 |
Correct |
56 ms |
12068 KB |
Output is correct |
36 |
Correct |
55 ms |
12024 KB |
Output is correct |
37 |
Correct |
57 ms |
12000 KB |
Output is correct |
38 |
Correct |
53 ms |
12044 KB |
Output is correct |
39 |
Correct |
62 ms |
11972 KB |
Output is correct |
40 |
Correct |
53 ms |
11960 KB |
Output is correct |
41 |
Correct |
57 ms |
11956 KB |
Output is correct |
42 |
Correct |
51 ms |
12048 KB |
Output is correct |
43 |
Correct |
48 ms |
12028 KB |
Output is correct |
44 |
Correct |
47 ms |
12056 KB |
Output is correct |
45 |
Correct |
46 ms |
12020 KB |
Output is correct |
46 |
Correct |
49 ms |
12036 KB |
Output is correct |
47 |
Correct |
47 ms |
11988 KB |
Output is correct |
48 |
Correct |
52 ms |
11956 KB |
Output is correct |
49 |
Correct |
56 ms |
12080 KB |
Output is correct |
50 |
Correct |
71 ms |
12052 KB |
Output is correct |
51 |
Correct |
61 ms |
11980 KB |
Output is correct |
52 |
Correct |
61 ms |
11980 KB |
Output is correct |
53 |
Correct |
67 ms |
12068 KB |
Output is correct |
54 |
Correct |
61 ms |
11948 KB |
Output is correct |
55 |
Correct |
65 ms |
12004 KB |
Output is correct |
56 |
Correct |
69 ms |
12028 KB |
Output is correct |
57 |
Correct |
61 ms |
12064 KB |
Output is correct |
58 |
Correct |
60 ms |
12048 KB |
Output is correct |
59 |
Correct |
74 ms |
12056 KB |
Output is correct |
60 |
Correct |
62 ms |
12084 KB |
Output is correct |
61 |
Correct |
8 ms |
8148 KB |
Output is correct |
62 |
Correct |
7 ms |
8112 KB |
Output is correct |
63 |
Correct |
7 ms |
8148 KB |
Output is correct |
64 |
Correct |
7 ms |
8148 KB |
Output is correct |
65 |
Correct |
40 ms |
12020 KB |
Output is correct |
66 |
Correct |
30 ms |
10748 KB |
Output is correct |
67 |
Correct |
60 ms |
12060 KB |
Output is correct |
68 |
Correct |
13 ms |
8728 KB |
Output is correct |
69 |
Correct |
7 ms |
8148 KB |
Output is correct |
70 |
Correct |
7 ms |
8148 KB |
Output is correct |
71 |
Correct |
7 ms |
8096 KB |
Output is correct |