Submission #974617

#TimeUsernameProblemLanguageResultExecution timeMemory
974617alextodoranBinaria (CCO23_day1problem1)C++17
0 / 25
3 ms500 KiB
/** _ _ __ _ _ _ _ _ _ |a ||t ||o d | |o | | __ _| | _ | __| _ | | __ |/_ | __ /__\ / _\| **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N_MAX = 1000000; const int MOD = (int) 1e6 + 3; int pwr (const int &a, const int &b) { if (b == 0) { return 1; } else if (b & 1) { return (ll) a * pwr(a, (b ^ 1)) % MOD; } else { int aux = pwr(a, (b >> 1)); return (ll) aux * aux % MOD; } } int inv (const int &a) { return pwr(a, MOD - 2); } int main () { ios_base::sync_with_stdio(false); cin.tie(0); int N, K; cin >> N >> K; int A[N - K + 1]; for (int i = 0; i < N - K + 1; i++) { cin >> A[i]; } int B[N - K + 1]; fill(B, B + N - K + 1, -1); for (int i = N - K - 1; i >= 0; i--) { if (A[i] < A[i + 1]) { B[i] = 0; } else if (A[i] > A[i + 1]) { B[i] = 1; } else { B[i] = (i + K < N - K + 1 ? B[i + K] : -1); } } int cnt = 0, sum = A[0]; for (int i = 0; i < K; i++) { cnt += (B[i] == -1); sum -= (B[i] == 1); } int answer = 1; for (int i = 1; i <= cnt - sum; i++) { answer = (ll) answer * i % MOD; } answer = inv(answer); for (int i = sum + 1; i <= cnt; i++) { answer = (ll) answer * i % MOD; } cout << answer << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...