60472023-10-28 20:13:27IgnácLegtöbb unoka (80 pont)cpp11Accepted 80/809ms6852 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N;
	int M;
	cin >> N >> M;
	vector<vector<int>> a(N + 1);
	for(int i = 0; i < M; i++){
		int x, y;
		cin >> x >> y;
		a[x].push_back(y);
	}

	pair<int, int> legnagyobb;
	legnagyobb.first = 0;
	legnagyobb.second = -1;
	int osszeg = 0;
	for(int i = 1; i < N; i++){
		osszeg = 0;
		for(int j = 0; j < a[i].size(); j++){
			osszeg += a[a[i][j]].size();
		}
		if(osszeg > legnagyobb.first){
			legnagyobb.first = osszeg;
			legnagyobb.second = i;
		}
	}

	if(legnagyobb.second == -1){
		cout << -1;
	} 
	else{
		cout << legnagyobb.second << " " << legnagyobb.first;
	}
}
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/03ms2084 KiB
2Accepted0/06ms2808 KiB
3Accepted4/43ms2404 KiB
4Accepted4/43ms2452 KiB
5Accepted4/48ms3500 KiB
6Accepted4/48ms3844 KiB
7Accepted4/43ms3304 KiB
8Accepted4/43ms3380 KiB
9Accepted4/46ms3964 KiB
10Accepted4/48ms4628 KiB
11Accepted4/48ms4668 KiB
12Accepted4/46ms4924 KiB
13Accepted4/49ms5424 KiB
14Accepted4/48ms5492 KiB
15Accepted4/48ms5612 KiB
16Accepted4/48ms5700 KiB
17Accepted4/48ms5920 KiB
18Accepted4/49ms6020 KiB
19Accepted2/23ms5636 KiB
20Accepted2/23ms5844 KiB
21Accepted3/33ms5864 KiB
22Accepted3/34ms6112 KiB
23Accepted3/38ms6744 KiB
24Accepted3/38ms6852 KiB