58142023-10-02 17:38:22HoraVállalkozócpp11Wrong answer 10/4034ms4348 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> nap(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> nap[i];
  }
  vector<int> h(m);
  for (int i = 0; i < m; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  int a = 1;
  int marad = nap[a];
  int eddig = 0;
  for (int i = 0; i < m; i++) {
    while (a > h[i]) {
      a++;
      if(a > n){
        cout << eddig;
        return 0;
      }
      marad = nap[a];
    }
    while(marad == 0){
      a++;
      if(a > n){
        cout << eddig;
        return 0;
      }
      marad = nap[a];
    }
    if (marad > 0 && a <= h[i]) {
      marad--;
      eddig++;
    }
  }
  cout << eddig;
}
SubtaskSumTestVerdictTimeMemory
base10/40
1Accepted0/03ms2088 KiB
2Wrong answer0/034ms2732 KiB
3Accepted2/23ms2220 KiB
4Accepted2/22ms2296 KiB
5Wrong answer0/23ms2440 KiB
6Wrong answer0/23ms2692 KiB
7Wrong answer0/24ms2760 KiB
8Wrong answer0/23ms2876 KiB
9Wrong answer0/24ms3208 KiB
10Wrong answer0/23ms3188 KiB
11Wrong answer0/24ms3448 KiB
12Wrong answer0/24ms3448 KiB
13Wrong answer0/24ms3464 KiB
14Wrong answer0/24ms3452 KiB
15Wrong answer0/210ms3676 KiB
16Wrong answer0/210ms3548 KiB
17Accepted2/216ms3876 KiB
18Accepted2/210ms3984 KiB
19Accepted2/213ms4016 KiB
20Wrong answer0/217ms3920 KiB
21Wrong answer0/224ms3960 KiB
22Wrong answer0/234ms4348 KiB