854B - Maxim Buys an Apartment - CodeForces Solution


constructive algorithms math *1200

Please click on ads to support us..

C++ Code:

//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const int N=1e6+5,mod=1e9+7;
typedef long long ll;
typedef pair<int,int> PII;
void solve()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int mi,mx;
    if(k==0) mi=0,mx=0;
    else
    {
        if(n==k)
        {
            printf("0 0\n");
            return;
        }
        mi=1;
        int a=n-k,b=k;
        mx=min(b,a/2)*2+a%2;
        mx=min(mx,b*2);
    }
    printf("%d %d\n",mi,mx);
}
int main()
{
    int t=1;
    //scanf("%d",&t);
    while(t--) solve();
    return 0;
}


Comments

Submit
0 Comments
More Questions

519C - A and B and Team Training
631A - Interview
961B - Lecture Sleep
522A - Reposts
1166D - Cute Sequences
1176A - Divide it
1527A - And Then There Were K
1618E - Singers' Tour
1560B - Who's Opposite
182B - Vasya's Calendar
934A - A Compatible Pair
1618F - Reverse
1684C - Column Swapping
57C - Array
1713D - Tournament Countdown
33A - What is for dinner
810A - Straight A
1433C - Dominant Piranha
633A - Ebony and Ivory
1196A - Three Piles of Candies
299A - Ksusha and Array
448B - Suffix Structures
1092B - Teams Forming
1166C - A Tale of Two Lands
544B - Sea and Islands
152B - Steps
1174D - Ehab and the Expected XOR Problem
1511A - Review Site
1316A - Grade Allocation
838A - Binary Blocks