Created
June 25, 2019 07:17
-
-
Save kei9327/7cb996c96f917f3e2776be075806818c to your computer and use it in GitHub Desktop.
HackerRank>Algorithm>implementation>pageCount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int pageCount(int n, int p) { | |
return min(p/2, n/2 - p/2); | |
} | |
int main() | |
{ | |
ofstream fout(getenv("OUTPUT_PATH")); | |
int n; | |
cin >> n; | |
cin.ignore(numeric_limits<streamsize>::max(), '\n'); | |
int p; | |
cin >> p; | |
cin.ignore(numeric_limits<streamsize>::max(), '\n'); | |
int result = pageCount(n, p); | |
fout << result << "\n"; | |
fout.close(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment