152972025-02-18 09:10:05MezeiDavidLeghosszabb nyaralás (75 pont)cpp17Time limit exceeded 21/75300ms1576 KiB
#include <iostream>
#include <vector>
 
using namespace std;
 
int ossz(vector<int> n)
{
    int k = 0;
    for(int i = 0; i < n.size(); i++)
    {
        k += n[i];
    }
    return k;
}
 
int nem_0_vector (vector<int> n)
{
    int k = 0;
    for(int i = 0; i < n.size(); i++)
    {
        if(n[i] == 0)
            break;
        else
            k++;
    }
    return k;
}
 
int main()
{
    int n, napok_szam;
    cin >> n >> napok_szam;
    vector<int> napok (n);
    for(int i = 0; i < n; i++)
    {
        cin >> napok[i];
    }
    int max_hossz = 0;
    for(int i = 0; i < n; i++)
    {
        int j = 0;
        vector<int> nyaralas(n, 0);
        while(ossz(nyaralas) < napok_szam && i + j <= n)
        {
            //cout << ossz(nyaralas) << "a ";
            nyaralas[j] = napok[i + j];
            j++;
        }
        if(ossz(nyaralas) > napok_szam)
        {
            //cout << ossz(nyaralas) << "b ";
            nyaralas[j - 1] = 0;
            if(nem_0_vector(nyaralas) > max_hossz)
            {
                max_hossz = nem_0_vector(nyaralas);
                //cout << nem_0_vector(nyaralas) << "c ";
            }
        }
        //cout << endl;
    }
    cout << max_hossz;
    return 0;
}
 
SubtaskSumTestVerdictTimeMemory
base21/75
1Accepted0/01ms512 KiB
2Time limit exceeded0/0291ms1452 KiB
3Accepted3/31ms316 KiB
4Wrong answer0/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Wrong answer0/41ms316 KiB
9Accepted4/434ms316 KiB
10Accepted5/5200ms412 KiB
11Time limit exceeded0/5300ms316 KiB
12Time limit exceeded0/5275ms436 KiB
13Time limit exceeded0/7282ms1572 KiB
14Time limit exceeded0/7289ms1576 KiB
15Time limit exceeded0/7287ms1452 KiB
16Time limit exceeded0/8287ms1452 KiB
17Time limit exceeded0/8279ms1452 KiB