# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
700652 |
2023-02-19T08:03:54 Z |
Nursik |
W (RMI18_w) |
C++14 |
|
222 ms |
23800 KB |
#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;
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 time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
1236 KB |
Output isn't correct |
4 |
Incorrect |
22 ms |
4664 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Incorrect |
13 ms |
6100 KB |
Output isn't correct |
4 |
Incorrect |
56 ms |
10776 KB |
Output isn't correct |
5 |
Incorrect |
131 ms |
15352 KB |
Output isn't correct |
6 |
Incorrect |
222 ms |
23800 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
1112 KB |
Output isn't correct |
8 |
Incorrect |
12 ms |
2516 KB |
Output isn't correct |
9 |
Incorrect |
28 ms |
3660 KB |
Output isn't correct |
10 |
Incorrect |
201 ms |
23400 KB |
Output isn't correct |