Skip to content

Instantly share code, notes, and snippets.

@kei9327
Created June 25, 2019 07:17
Show Gist options
  • Save kei9327/7cb996c96f917f3e2776be075806818c to your computer and use it in GitHub Desktop.
Save kei9327/7cb996c96f917f3e2776be075806818c to your computer and use it in GitHub Desktop.
HackerRank>Algorithm>implementation>pageCount
#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