40782023-03-13 08:37:24tamasmarkNegáló rendezés (55 pont)cpp17Accepted 55/5537ms7540 KiB
// bgalo rendezes.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

long long y[100000],sum;
vector<long long>x;
int i, n,db,maxi,mini,a;

int main()
{
    cin >> n;
    x.resize(n + 1);
    mini = INT_MAX;
    maxi = INT_MIN;
    for (i = 1; i <= n; ++i)
    {
        cin >> x[i];
        y[x[i]]++;
        a = x[i];
        maxi = max(maxi, a);
        mini = min(mini, a);
    }
    db = 1;
    for (i = mini; i <= maxi; ++i)
    {
        if (y[i]!=0)
        {
            if (db == 1)
            {
                sum = 1;
                db++;
            }
            else
            {
                sum = sum * (y[i] + 1)%1000000007;
            }
        }
    }
    cout << sum;
    return 0;
}
/*
5
5 1 2 3 2
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/03ms1888 KiB
2Accepted0/035ms5112 KiB
3Accepted2/23ms2676 KiB
4Accepted2/23ms2596 KiB
5Accepted2/23ms2676 KiB
6Accepted2/23ms2680 KiB
7Accepted3/33ms3040 KiB
8Accepted2/23ms3472 KiB
9Accepted3/34ms4888 KiB
10Accepted3/332ms6328 KiB
11Accepted3/335ms6408 KiB
12Accepted3/335ms5108 KiB
13Accepted3/334ms5256 KiB
14Accepted3/335ms6596 KiB
15Accepted3/335ms6596 KiB
16Accepted3/337ms6852 KiB
17Accepted3/334ms6924 KiB
18Accepted3/335ms7280 KiB
19Accepted3/335ms7396 KiB
20Accepted3/335ms7340 KiB
21Accepted3/332ms7416 KiB
22Accepted3/335ms7540 KiB