Solution to 'Drawing Book' (HackerRank)
Hi all!
Here's, my solution to the problem 'Drawing Book' from HackerRank.
Question link: https://www.hackerrank.com/challenges/drawing-book/problem
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,p;
cin>>n;
cin>>p;
int ans1=p/2;
if(n%2==0) n++;
int ans2=(n-p)/2;
int ans=min(ans1,ans2);
cout<<ans;
return 0;
}
Comments
Post a Comment