Codeforces B. Vasya and Isolated Vertices

Codeforces B. Vasya and Isolated Vertices

Problem Link
Solution:

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define mod 1000000007
#define MAX 100010

using namespace std;

typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;
typedef vector<vii> vvii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main(){_

    ll n;
    ll e;
    ll i = 0;
    ll mn, mx;
    ll qnt;

    cin >> n >> e;

    if(e*2 >= n)
        mn = 0;
    else{
        mn = n-(e*2);
    }

    mx = 0;
    i = 2;
    while(e > mx){
        mx += i-1;
        i++;
    }
    i--;

    mx = max(n-i, 0LL);
    if(e == 0)
        mx = n;
    cout << mn << " " << mx << endl;

}

No comments

Theme images by enjoynz. Powered by Blogger.