31192023-02-16 21:29:50baranyimarcellHús sütés (75 pont)cpp17Time limit exceeded 42/75446ms12564 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, mxh, mn;
    for (i=0; i<N; i++)
    {
        cin>>hus[i];
        if (i==0) mn=hus[0];
        db[hus[i]]+=1;
        if (count(kulonb.begin(), kulonb.end(), hus[i])==false)
        {
            kulonb.push_back(hus[i]);
        }
        //if (hus[i]>mx) mx=hus[i];
        if (hus[i]<mn) mn=hus[i];
    }
    int ki=0;
    /*vector<int> csokkeno;
    for (i=0; i<kulonb.size(); i++)
    {
        for (j=0; j<kulonb.size(); j++)
        {
            if (kulonb[j]>mx) mx=kulonb[j], mxh=j;
        }
        csokkeno.push_back(mx);
        mx=0;
        kulonb[mxh]=mn;
        //cout<<csokkeno[i]<<endl;;
    }*/
    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/06ms9812 KiB
3Time limit exceeded0/0400ms5860 KiB
4Accepted3/36ms9904 KiB
5Accepted3/36ms10164 KiB
6Accepted3/36ms10112 KiB
7Accepted3/36ms10376 KiB
8Accepted4/46ms10656 KiB
9Accepted4/46ms10548 KiB
10Accepted4/46ms10544 KiB
11Accepted4/46ms10944 KiB
12Accepted4/47ms11016 KiB
13Time limit exceeded0/4400ms7212 KiB
14Time limit exceeded0/4372ms7388 KiB
15Time limit exceeded0/5381ms7268 KiB
16Time limit exceeded0/5365ms7380 KiB
17Time limit exceeded0/5379ms7320 KiB
18Time limit exceeded0/4432ms7500 KiB
19Time limit exceeded0/4351ms7712 KiB
20Accepted4/443ms12364 KiB
21Accepted4/4122ms12396 KiB
22Time limit exceeded0/2446ms7632 KiB
23Accepted2/223ms12564 KiB