146232025-01-21 11:38:19PappMatyasZebra (75 pont)python3Futási hiba 0/7516ms3256 KiB
#include <iostream>

using namespace std;

bool LastVal(int A[80], int type, int st, int n)
{
    for(int i = st + 1; i < n; i++)
    {
        if(A[i] == type)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int n, A[80], C[80], nopw = 1, ans = 0, type, curtime;
    bool setnew = true;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    for(int i = 0; i < n ;i++)
    {
        cin >> C[i];
    }
    for(int i = 0; i < n; i++)
    {
        if(setnew)
        {
            setnew = false;
            type = 1 - A[i];
            curtime = C[i];
            nopw = 1;
            //cout << i << " new val\n";
        }
        else
        if(A[i] == type)
        {
            if(LastVal(A, type, i, n))
            {
                type = -1;
                ans+= nopw * (C[i] - curtime);
                nopw++;
                curtime = C[i];
                //cout << i << " final value \n";
            }
            else
            {
                ans+= nopw * (C[i] - curtime);
                setnew = true;
                //cout << i << " type not final\n";
            }
        }
        else
        {
            ans+= nopw * (C[i] - curtime);
            //cout << i << " increase " << nopw * (C[i] - curtime);
            nopw++;
            curtime = C[i];
            //cout << " new nopw " << nopw << " new time " << curtime << endl;
        }
    }
    cout << ans;
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base0/75
1Futási hiba0/016ms3212 KiB
2Futási hiba0/016ms3060 KiB
3Futási hiba0/516ms2992 KiB
4Futási hiba0/516ms2868 KiB
5Futási hiba0/516ms2868 KiB
6Futási hiba0/516ms2868 KiB
7Futási hiba0/514ms3180 KiB
8Futási hiba0/516ms2884 KiB
9Futási hiba0/516ms2900 KiB
10Futási hiba0/516ms2876 KiB
11Futási hiba0/514ms2948 KiB
12Futási hiba0/516ms3060 KiB
13Futási hiba0/516ms3256 KiB
14Futási hiba0/516ms2888 KiB
15Futási hiba0/516ms3056 KiB
16Futási hiba0/516ms2868 KiB
17Futási hiba0/514ms2872 KiB