10482022-02-27 15:12:20nmarciVállalkozócpp11Accepted 40/4014ms4680 KiB
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <queue>
#include <string>
#include <limits>
#include <map>
#include <algorithm>
#include <stack>

using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  for(auto& i : v)
    cin >> i;
  vector<int> munka(m);
  for(auto&i : munka){
    cin >> i;
  }
  sort(begin(munka), end(munka));
  int sol = 0, ptr = 0;
  for(int i = 0; i < n; ++i){
    while(ptr < m && munka[ptr] < i + 1) ++ptr;
    sol += min(m - ptr, v[i]);
    ptr += min(m - ptr, v[i]);
  }
  cout << sol << endl;
} 
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/02ms1756 KiB
2Accepted0/014ms2896 KiB
3Accepted2/21ms2248 KiB
4Accepted2/21ms2244 KiB
5Accepted2/21ms2248 KiB
6Accepted2/21ms2268 KiB
7Accepted2/22ms2288 KiB
8Accepted2/22ms2300 KiB
9Accepted2/22ms2320 KiB
10Accepted2/21ms2316 KiB
11Accepted2/22ms2340 KiB
12Accepted2/22ms2352 KiB
13Accepted2/22ms2384 KiB
14Accepted2/22ms2404 KiB
15Accepted2/24ms2652 KiB
16Accepted2/26ms2752 KiB
17Accepted2/26ms3060 KiB
18Accepted2/24ms3204 KiB
19Accepted2/24ms3348 KiB
20Accepted2/28ms3560 KiB
21Accepted2/212ms3884 KiB
22Accepted2/214ms4680 KiB