# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1029618 |
2024-07-21T06:09:24 Z |
atom |
Magneti (COCI21_magneti) |
C++17 |
|
1 ms |
856 KB |
#include "bits/stdc++.h"
// @JASPER'S BOILERPLATE
using namespace std;
using ll = long long;
#ifdef JASPER
#include "debug.h"
#else
#define debug(...) 166
#endif
const int MOD = 1e9 + 7;
const int N = 2e4 + 5;
int bPow(int a, int b) {
ll ans = 1;
while (b) {
if (b & 1) ans = (1LL * ans * a) % MOD;
a = (1LL * a * a) % MOD;
b >>= 1;
}
return ans;
}
int fac[N], inv[N];
void prepare() {
fac[0] = 1;
for (int i = 1; i < N; ++i)
fac[i] = (1LL * fac[i - 1] * i) % MOD;
inv[N - 1] = bPow(fac[N - 1], MOD - 2);
for (int i = N - 2; i >= 0; --i)
inv[i] = (1LL * inv[i + 1] * (i + 1)) % MOD;
}
int C(int k, int n) {
if (k > n) return 0;
return ((1LL * fac[n] * inv[n - k]) % MOD * (inv[k])) % MOD;
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#ifdef JASPER
freopen("in1", "r", stdin);
#endif
prepare();
int n, l;
cin >> n >> l;
vector <int> a(n + 1);
for (int i = 1; i <= n; ++i) cin >> a[i];
sort(a.begin(), a.end());
if (a[1] == a[n]) {
// sub1
int p = (n - 1) * a[1] + 1;
ll ans = (1LL * fac[n] * C(n, n + l - p)) % MOD;
cout << ans << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
608 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
608 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Incorrect |
1 ms |
856 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |