31202023-02-16 21:32:51baranyimarcellHús sütés (75 pont)cpp17Time limit exceeded 42/75400ms12260 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int N, i, j;
    cin>>N;
    int hus[N];
    vector<int> db;
    db.resize(1000000);
    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]);
        }
    }
    int ki=0;
    sort(kulonb.begin(), kulonb.end(), std::greater<int>());
    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/06ms9528 KiB
2Accepted0/04ms9720 KiB
3Time limit exceeded0/0400ms5852 KiB
4Accepted3/34ms10184 KiB
5Accepted3/34ms10140 KiB
6Accepted3/34ms10384 KiB
7Accepted3/34ms10600 KiB
8Accepted4/44ms10524 KiB
9Accepted4/46ms10784 KiB
10Accepted4/46ms10808 KiB
11Accepted4/46ms11068 KiB
12Accepted4/46ms11080 KiB
13Time limit exceeded0/4374ms7216 KiB
14Time limit exceeded0/4386ms7240 KiB
15Time limit exceeded0/5370ms7044 KiB
16Time limit exceeded0/5377ms7152 KiB
17Time limit exceeded0/5384ms7472 KiB
18Time limit exceeded0/4368ms7444 KiB
19Time limit exceeded0/4360ms7628 KiB
20Accepted4/443ms12136 KiB
21Accepted4/4120ms12136 KiB
22Time limit exceeded0/2363ms7656 KiB
23Accepted2/223ms12260 KiB