58552023-10-04 15:19:58horkaVállalkozócpp11Accepted 40/4027ms4748 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,m; cin>>n>>m;
    vector<int> munkaora(n+1),munkak(n+1),hatarido(m+1);
    for(int i=1; i<=n; i++)
        cin>>munkaora[i];
    for(int i=1; i<=m; i++)
    {
        cin>>hatarido[i];
        munkak[hatarido[i]]++;
    }
    int extra=0;
    for(int i=1; i<=n; i++)
    {
        extra+=munkaora[i];
        if(extra>=munkak[i])
        {
            extra-=munkak[i];
            munkak[i]=0;
        }
        else
        {
            munkak[i]-=extra;
            extra=0;
        }
    }
    int mo=m;
    for(int i=1; i<=n; i++)
        mo-=munkak[i];
        cout<<mo<<endl;


}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1816 KiB
2Accepted0/027ms2760 KiB
3Accepted2/22ms2084 KiB
4Accepted2/22ms2084 KiB
5Accepted2/22ms2224 KiB
6Accepted2/23ms2344 KiB
7Accepted2/24ms2560 KiB
8Accepted2/23ms2628 KiB
9Accepted2/24ms2768 KiB
10Accepted2/23ms2832 KiB
11Accepted2/24ms3092 KiB
12Accepted2/23ms3068 KiB
13Accepted2/24ms3084 KiB
14Accepted2/24ms3284 KiB
15Accepted2/28ms3636 KiB
16Accepted2/29ms3772 KiB
17Accepted2/214ms3676 KiB
18Accepted2/210ms4060 KiB
19Accepted2/213ms4128 KiB
20Accepted2/214ms4056 KiB
21Accepted2/218ms4472 KiB
22Accepted2/226ms4748 KiB