fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, k;
  6. cin >> n >> k;
  7.  
  8. int moves = 0, throws = 0, picks = 0;
  9.  
  10. if (k <= (n / 2)) {
  11. moves += (k - 1);
  12. } else {
  13. moves += (n - k);
  14. }
  15.  
  16. moves += (n - 1);
  17. picks += n;
  18. throws += (n + 1);
  19.  
  20. cout << (moves + throws + picks);
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 15232KB
stdin
2 2
stdout
6