58232023-10-02 21:11:26mmatedVállalkozócpp11Accepted 40/4018ms5476 KiB
#include <bits/stdc++.h>
using namespace std;
#define f(i,k,n) for(int i=k; i<n; i++)
#define ll long long
const int inf = INT_MAX;

void solve()
{
    int n,m;
    cin>>n>>m;
    int a[n];
    int b[m];
    f(i,0,n)    cin>>a[i];
    f(i,0,m)    cin>>b[i];
    sort(b,b+m);
    int i=0, k=0;    //hanyadik nap,    hany munka volt ezen a napon
    int j=0;    //hanyadik munka (rendezve)
    int c=0;
    while(i<n && j<m)
    {
        if(i+1<=b[j] && k<a[i])
        {
            c++;
            k++;
            j++;
        }
        else if(k<a[i] && i+1>b[j])
        {
            k=0;
            j++;
        }
        else
        {
            k=0;
            i++;
        }
    }
    cout<<c;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms2016 KiB
2Accepted0/018ms2920 KiB
3Accepted2/23ms2256 KiB
4Accepted2/23ms2492 KiB
5Accepted2/22ms2588 KiB
6Accepted2/23ms2712 KiB
7Accepted2/24ms3012 KiB
8Accepted2/23ms2948 KiB
9Accepted2/23ms2960 KiB
10Accepted2/23ms3216 KiB
11Accepted2/23ms3412 KiB
12Accepted2/23ms3496 KiB
13Accepted2/24ms3524 KiB
14Accepted2/23ms3840 KiB
15Accepted2/27ms4296 KiB
16Accepted2/27ms4228 KiB
17Accepted2/28ms4292 KiB
18Accepted2/26ms4360 KiB
19Accepted2/27ms4476 KiB
20Accepted2/210ms4852 KiB
21Accepted2/214ms5276 KiB
22Accepted2/218ms5476 KiB