31212023-02-16 21:42:49baranyimarcellHús sütés (75 pont)cpp17Time limit exceeded 42/75448ms12624 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int N, i, j;
    cin>>N;
    int hus[N];
    vector<int> kulonb;
    int mx=0;
    for (i=0; i<N; i++)
    {
        cin>>hus[i];
        //db[hus[i]]+=1;
        if (count(kulonb.begin(), kulonb.end(), hus[i])==false)
        {
            kulonb.push_back(hus[i]);
        }
    }
    sort(kulonb.begin(), kulonb.end(), std::greater<int>());
    vector<int> db;
    db.resize(kulonb[0]+1);
    for (i=0; i<N; i++) db[hus[i]]+=1;
    int szml=0;
    for (i=0; i<kulonb.size(); i++)
    {
        szml+=db[kulonb[i]];
        if (szml+kulonb[i]-1>mx) mx=szml+kulonb[i]-1;
    }
    cout<<mx<<endl;
}
SubtaskSumTestVerdictTimeMemory
base42/75
1Accepted0/03ms1812 KiB
2Accepted0/03ms2056 KiB
3Time limit exceeded0/0388ms2008 KiB
4Accepted3/33ms2880 KiB
5Accepted3/33ms2720 KiB
6Accepted3/33ms2808 KiB
7Accepted3/33ms2988 KiB
8Accepted4/43ms3668 KiB
9Accepted4/43ms5312 KiB
10Accepted4/44ms10248 KiB
11Accepted4/44ms9532 KiB
12Accepted4/46ms9744 KiB
13Time limit exceeded0/4356ms3668 KiB
14Time limit exceeded0/4360ms3684 KiB
15Time limit exceeded0/5354ms3548 KiB
16Time limit exceeded0/5363ms3792 KiB
17Time limit exceeded0/5448ms3744 KiB
18Time limit exceeded0/4382ms3796 KiB
19Time limit exceeded0/4442ms3976 KiB
20Accepted4/443ms12624 KiB
21Accepted4/4167ms5092 KiB
22Time limit exceeded0/2356ms3908 KiB
23Accepted2/219ms5080 KiB