rengetsu

HackerRank_DrawingBook

Jun 19th, 2018
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. //Drawing Book
  2. #include <vector>
  3. #include <iostream>
  4. #include <algorithm>
  5. using namespace std;
  6. static int total_pages(const int& n) {
  7.     return (n + 2) / 2;
  8. }
  9. int main() {
  10.     int n,p;
  11.     cin >> n >> p;
  12.     int entire_book = total_pages(n);
  13.     int from_front = total_pages(p) - 1;
  14.     int from_back = entire_book - from_front - 1;
  15.     cout << std::min(from_front, from_back) << '\n';
  16.     return 0;
  17. }
Add Comment
Please, Sign In to add comment