| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 512 MB | 153 | 37 | 36 | 29.508% |
Joitter is a trending social media where you can share your memories with your friends.
In Joitter, you can follow other users. For example, when a user a follows another user b, user a can read user b’s posts on the timeline. In this case, it is possible that user b follows back user a or not. However, it is impossible that user a follows him/herself or user a follows a particular user b more than once.
N users, consisting of user 1, user 2, . . ., user N, have started using Joitter. At first, none of them follows any other users.
From now on, for M days, following events occur: user Ai follows user Bi on the i-th day (1 ≤ i ≤ M).
The official of Joitter is planning to hold a social exchange event on its service once during the M days. A social exchange event occurs as follows:
The official of Joitter still has not decided when to hold the social exchange event. So, they would like to know the maximum value of the total sum of the number of users each user follows after the social exchange event, if it happens right after the following event of the i-th day, for each i (1 ≤ i ≤ M). We assume that the social exchange event finishes before the following event on the next day.
Write a program that, given the number of users and following events during M days, calculates the maximum value of the total sum of the number of users each user follows after the social exchange event, if the social exchange event falls right after the following event of the i-th day, for each i (1 ≤ i ≤ M).
Read the following data from the standard input. All the values in the input are integers.
N M A1 B1 . . . AM BM
Write M lines to the standard output. In the i-th line (1 ≤ i ≤ M), output the maximum value of the total sum of the number of users each user follows after the social exchange event, if the social exchange event falls right after the following event of day i.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 1 | N ≤ 50. |
| 2 | 16 | N ≤ 2000. |
| 3 | 83 | No additional constraints. |
4 6 1 2 2 3 3 2 1 3 3 4 4 3
1 2 4 4 5 9
6 10 1 2 2 3 3 4 4 5 5 6 6 5 5 4 4 3 3 2 2 1
1 2 3 4 5 7 11 17 25 30