254312026-02-20 05:48:55fantomlanyMaximális szorzat (50 pont)cpp17Wrong answer 1/50600ms756 KiB
#include <iostream>

using namespace std;

int sorozat[100000];

int main()
{
    int n,k,b/*, sorozat[10]*/, x=1, nullashelye=-1;
    long long szorzat=1;
    bool csere=1;
    cin>>n>>k>>b;
    for(int i=0;i<n;i++)
    {
        cin>>sorozat[i];
    }
    while(csere)
    {
        csere=0;
        for(int i=0;i<n-x;i++)
        {
            if(sorozat[i]<sorozat[i+1])
            {
                swap(sorozat[i],sorozat[i+1]);
                csere=1;
            }
        }
        x++;
    }
    csere=0; x=0;
    while(!csere && x<n)
    {
        if(sorozat[x]==0)
        {
            nullashelye=x;
            csere=1;
        }
        x++;
    }
    x=b;
    for(int j=0;j<k;j++)
    {
        if(sorozat[x]<0)
        {
            sorozat[x]++;
        }
        else if(sorozat[x]==0 && x<n-1 && sorozat[x+1]<0)
             {
                 x++;
                 sorozat[x]++;
             }
             else if(sorozat [x]==0 && x<n-1)
                  {
                      sorozat[x]++;
                      if(x+1<n-1 && sorozat[x+1]==0)
                      {
                          x++;
                      }
                      else
                      {
                          x=b;
                      }
                  }
                  else
                  {
                      sorozat[x]++;
                      if(sorozat[x]!=1 && x<n-1) x++;
                      else if(x==n-1)x=0;
                  }


    }
    for(int i=0;i<n;i++)
    {
        szorzat*=sorozat[i];
    }
    if(szorzat >= 0)
        cout<<szorzat;
    else cout<<-1;



    return 0;
}
SubtaskSumTestVerdictTimeMemory
base1/50
1Wrong answer0/01ms500 KiB
2Wrong answer0/01ms508 KiB
3Wrong answer0/01ms316 KiB
4Accepted0/01ms316 KiB
5Wrong answer0/0361ms444 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/24ms316 KiB
10Wrong answer0/2368ms444 KiB
11Time limit exceeded0/2600ms544 KiB
12Time limit exceeded0/1600ms664 KiB
13Wrong answer0/14ms508 KiB
14Wrong answer0/1370ms592 KiB
15Time limit exceeded0/1600ms564 KiB
16Time limit exceeded0/1580ms564 KiB
17Time limit exceeded0/1600ms564 KiB
18Accepted1/19ms564 KiB
19Time limit exceeded0/1584ms564 KiB
20Time limit exceeded0/1583ms564 KiB
21Time limit exceeded0/1574ms564 KiB
22Time limit exceeded0/1600ms564 KiB
23Time limit exceeded0/1586ms756 KiB
24Time limit exceeded0/1587ms564 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/2370ms316 KiB
27Time limit exceeded0/2598ms496 KiB
28Time limit exceeded0/1583ms564 KiB
29Time limit exceeded0/2583ms564 KiB
30Time limit exceeded0/1600ms564 KiB
31Time limit exceeded0/1577ms564 KiB
32Wrong answer0/24ms500 KiB
33Time limit exceeded0/2600ms744 KiB
34Time limit exceeded0/1578ms564 KiB
35Time limit exceeded0/2600ms612 KiB
36Time limit exceeded0/2586ms564 KiB
37Time limit exceeded0/2578ms564 KiB
38Time limit exceeded0/2584ms564 KiB
39Wrong answer0/11ms316 KiB