Dang_Quan_10_Tin

Untitled

Feb 20th, 2021
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using ll = long long;
  4. using ld = long double;
  5. using ull = unsigned long long;
  6.  
  7. const int N = 1e5 + 5;
  8. const int Inf = 1e19 + 7;
  9. int n, m, k;
  10. int maxn(0), minn(0), cur(0);
  11. int a[N];
  12.  
  13. void Read()
  14. {
  15.     cin >> n >> m >> k;
  16.     while (m--)
  17.     {
  18.         int v;
  19.         cin >> v;
  20.         if (v == 1)
  21.             --cur;
  22.         else
  23.             ++cur;
  24.         minn = min(minn, cur);
  25.         maxn = max(maxn, cur);
  26.     }
  27.     for (int i = 1; i <= k; ++i)
  28.         cin >> a[i];
  29.     a[0] = 0;
  30.     a[k + 1] = n + 1;
  31. }
  32.  
  33. void Solve()
  34. {
  35.     int ans(0);
  36.     for (int i = 1; i <= k + 1; ++i)
  37.         ans += max(0, a[i] - maxn - 1 - (a[i - 1] + abs(minn) + 1) + 1);
  38.     cout << ans;
  39. }
  40.  
  41. int32_t main()
  42. {
  43.     ios::sync_with_stdio(0);
  44.     cin.tie(0);
  45.     cout.tie(0);
  46.     Read();
  47.     Solve();
  48. }
RAW Paste Data