58702023-10-04 17:32:51EsVagyVállalkozócpp17Accepted 40/4026ms3988 KiB
// Vallakozo.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int days, tasks;
    cin >> days >> tasks;
    vector<int> availability;
    for (int i = 0; i < days; i++)
    {
        int val;
        cin >> val;
        availability.push_back(val);
    }
    for (int i = 0; i < tasks; i++)
    {
        int day;
        cin >> day;
        day -= 1;
        availability[day]--;
    }
    int ans = tasks;
    for (int i = 0; i < days; i++)
    {
        if (availability[i] < 0)
        {
            ans += availability[i];
        }
        else
        {
            if (i + 1 < availability.size())
            {
                availability[i + 1] += availability[i];
            }
        }
    }
    cout << ans;

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/026ms2064 KiB
3Accepted2/23ms2292 KiB
4Accepted2/23ms2492 KiB
5Accepted2/23ms2696 KiB
6Accepted2/23ms2884 KiB
7Accepted2/24ms3100 KiB
8Accepted2/23ms3276 KiB
9Accepted2/24ms3360 KiB
10Accepted2/23ms3492 KiB
11Accepted2/23ms3600 KiB
12Accepted2/23ms3724 KiB
13Accepted2/24ms3816 KiB
14Accepted2/24ms3784 KiB
15Accepted2/28ms3808 KiB
16Accepted2/29ms3888 KiB
17Accepted2/214ms3988 KiB
18Accepted2/210ms3988 KiB
19Accepted2/213ms3984 KiB
20Accepted2/214ms3908 KiB
21Accepted2/218ms3892 KiB
22Accepted2/226ms3892 KiB