59772023-10-08 12:08:271478Vállalkozócpp17Hibás válasz 32/4034ms4696 KiB
#include <bits/stdc++.h>  
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
int main()
{
    //ifstream cin("in.txt");
    int n;
    cin >> n;
    int m;
    cin >> m;

    vector<int> workHours(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> workHours[i];
    }

    vector<int> deadlines(m + 1);
    for(int i = 1; i <= m; i++){
        cin >> deadlines[i];
    }

    sort(deadlines.begin(), deadlines.end());

    int ans = 0;

    for(int i = 1; i <= m; i++){
        if(deadlines[i] != deadlines[i - 1]){
            workHours[deadlines[i]] += workHours[deadlines[i - 1]];
        }

        if(workHours[deadlines[i]] > 0){
            workHours[deadlines[i]]--;
            ans++;
        }
    }

    cout << ans;
    
}

/*
    2 0 6
    2 3 1 2 3



*/
RészfeladatÖsszpontTesztVerdiktIdőMemória
base32/40
1Elfogadva0/03ms1808 KiB
2Elfogadva0/034ms2708 KiB
3Hibás válasz0/23ms2224 KiB
4Elfogadva2/23ms2432 KiB
5Elfogadva2/23ms2676 KiB
6Elfogadva2/24ms2864 KiB
7Elfogadva2/24ms3088 KiB
8Elfogadva2/23ms3284 KiB
9Elfogadva2/24ms3376 KiB
10Elfogadva2/23ms3496 KiB
11Elfogadva2/24ms3716 KiB
12Elfogadva2/24ms3792 KiB
13Elfogadva2/24ms3932 KiB
14Elfogadva2/24ms4008 KiB
15Elfogadva2/210ms4236 KiB
16Elfogadva2/210ms4228 KiB
17Hibás válasz0/214ms4180 KiB
18Hibás válasz0/210ms4260 KiB
19Hibás válasz0/213ms4276 KiB
20Elfogadva2/217ms4268 KiB
21Elfogadva2/225ms4304 KiB
22Elfogadva2/234ms4696 KiB