Submission #700670

# Submission time Handle Problem Language Result Execution time Memory
700670 2023-02-19T08:09:50 Z Nursik W (RMI18_w) C++14
0 / 100
266 ms 21724 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;
            if (cnt[x] >= 2){
                ll kol = fact[n - 2] * bp(fact[cnt[y]], mod - 2) % mod * bp(fact[cnt[x]], mod - 2) % mod;
                kol = (kol - (n - 2 - cnt[x] + 1) + mod) % mod;
                ans += kol;        
            }
        }
        cout << ans;
    }
}


# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 6 ms 852 KB Output isn't correct
4 Incorrect 28 ms 3760 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 21 ms 5892 KB Output isn't correct
4 Incorrect 87 ms 10064 KB Output isn't correct
5 Incorrect 191 ms 13908 KB Output isn't correct
6 Incorrect 243 ms 21724 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Incorrect 1 ms 212 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 3 ms 596 KB Output isn't correct
7 Incorrect 4 ms 980 KB Output isn't correct
8 Incorrect 19 ms 1876 KB Output isn't correct
9 Incorrect 30 ms 2656 KB Output isn't correct
10 Incorrect 266 ms 21284 KB Output isn't correct