fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7. int n, k;
  8. cin >> n >> k;
  9. vector<bool> branch(n + 1, false);
  10. for (int i = 0; i < k; i++) {
  11. int r;
  12. cin >> r;
  13. branch[r] = true;
  14. }
  15. ll ans = 0;
  16. for (int i = 1; i <= n; i++) {
  17. if (branch[i]) {
  18. ans = 2 * ans + 2;
  19. } else {
  20. ans++;
  21. }
  22. }
  23. cout << ans << '\n';
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5308KB
stdin
5 2
2 4
stdout
13