제출 #700660

#제출 시각아이디문제언어결과실행 시간메모리
700660NursikW (RMI18_w)C++14
0 / 100
363 ms21796 KiB
#include <iostream> #include <fstream> #include <iomanip> #include <vector> #include <set> #include <map> #include <cstring> #include <string> #include <cmath> #include <cassert> #include <ctime> #include <algorithm> #include <sstream> #include <list> #include <queue> #include <deque> #include <stack> #include <cstdlib> #include <cstdio> #include <iterator> #include <functional> #include <unordered_set> #include <unordered_map> #include <stdio.h> #include <bitset> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define f first #define s second #define ld long double const ll maxn = 1e6 + 1, maxm = 3e5 + 1; const ll mod = 1e9 + 7, cmod = 998244353, inf = 1e9, blck = 400, p2 = 31; const ld eps = 1e-9; int n, a[maxn], cnt[maxn];; ll fact[maxn]; int subtask1 = 0; ll bp(ll a, ll n){ ll res = 1; while (n > 0){ if (n & 1){ res *= a; } a *= a, n >>= 1; a %= mod, res %= mod; } return res; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; fact[0] = 1; set<int> setik; for (int i = 1; i <= n; ++i){ cin >> a[i]; cnt[a[i]] += 1; fact[i] = fact[i - 1] * i % mod; setik.insert(a[i]); } if (setik.size() == 2){ subtask1 = 1; } if (subtask1 > 0){ int x = *setik.begin(); int y = *setik.rbegin(); ll ans = 0; if (cnt[y] >= 2){ cnt[y] -= 2; if (cnt[x] >= 2){ ll kol = fact[n - 2] * bp(fact[cnt[y]], mod - 2) % mod * bp(fact[cnt[x]], mod - 2) % mod; kol -= (n - 2 - cnt[x] + 1); ans += kol; } } cout << ans; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...