CF1065B.Vasya and Isolated Vertices

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya has got an undirected graph consisting of nn vertices and mm edges. This graph doesn't contain any self-loops or multiple edges. Self-loop is an edge connecting a vertex to itself. Multiple edges are a pair of edges such that they connect the same pair of vertices. Since the graph is undirected, the pair of edges (1,2)(1, 2) and (2,1)(2, 1) is considered to be multiple edges. Isolated vertex of the graph is a vertex such that there is no edge connecting this vertex to any other vertex.

Vasya wants to know the minimum and maximum possible number of isolated vertices in an undirected graph consisting of nn vertices and mm edges.

瓦西娅得到了一个包含 nn 个顶点和 mm 条边的无向图。该图不包含任何自环或重边。自环是指连接某个顶点到其自身的边;重边是指连接同一对顶点的两条边。由于图是无向的,因此边 (1,2)(1, 2) 和 (2,1)(2, 1) 被视为重边。图中的孤立顶点是指不与任何其他顶点相连的顶点。

瓦西娅想知道:在包含 nn 个顶点和 mm 条边的无向图中,孤立顶点数的最小可能值和最大可能值分别是多少?

输入格式

The only line contains two integers nn and m (1≤n≤105,0≤m≤n(n−1)2)m~(1 \le n \le 10^5, 0 \le m \le \frac{n (n - 1)}{2}).

It is guaranteed that there exists a graph without any self-loops or multiple edges with such number of vertices and edges.

唯一的一行包含两个整数 nn 和 m (1≤n≤105,0≤m≤n(n−1)2)m~(1 \le n \le 10^5, 0 \le m \le \frac{n (n - 1)}{2})。

保证存在一个不含自环和重边的图,其顶点数和边数恰好分别为 nn 和 mm。

输出格式

In the only line print two numbers minmin and maxmax — the minimum and maximum number of isolated vertices, respectively.

在唯一的一行中输出两个数 minmin 和 maxmax —— 分别为孤立顶点的最小数量和最大数量。

输入输出样例

  • 输入#1

    4 2

    输出#1

    0 1
  • 输入#2

    3 1

    输出#2

    1 1

说明/提示

In the first example it is possible to construct a graph with 00 isolated vertices: for example, it should contain edges (1,2)(1, 2) and (3,4)(3, 4). To get one isolated vertex, we may construct a graph with edges (1,2)(1, 2) and (1,3)(1, 3).

In the second example the graph will always contain exactly one isolated vertex.

在第一个例子中,可以构造一个包含 00 个孤立顶点的图:例如,该图应包含边 (1,2)(1, 2) 和 (3,4)(3, 4)。要得到一个孤立顶点,我们可以构造一个包含边 (1,2)(1, 2) 和 (1,3)(1, 3) 的图。

在第二个例子中,该图将始终恰好包含一个孤立顶点。

输入解题思路,AI测评打分。不知道怎么写?

首页