37742023-03-02 21:49:22BttrngLegtöbb unoka (80 pont)cpp17Accepted 80/808ms5268 KiB
#include<bits/stdc++.h>
using namespace std;
vector<int>gy;
vector<int>u;


int main(){
  int n, m;
  cin>>n>>m;
  vector<vector<int> >s(n+1);
  gy.resize(n+1);
  u.resize(n+1);
  for(int i=1; i<=m; i++){
    int x, y;
    cin>>x>>y;
    s[x].push_back(y);
    gy[x]++;
  }
  int ln=0, sor;
  for(int i=1; i<=n; i++){
    for(int x : s[i]){
        u[i]+=gy[x];
    }
    if(ln<u[i]){
        ln=u[i];
        sor=i;
    }
  }
  if(ln!=0){
  cout<<sor<<" "<<ln<<endl;
  } else cout<<-1;

}
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/03ms1688 KiB
2Accepted0/06ms2764 KiB
3Accepted4/43ms2256 KiB
4Accepted4/42ms2392 KiB
5Accepted4/48ms3396 KiB
6Accepted4/48ms3524 KiB
7Accepted4/43ms2972 KiB
8Accepted4/43ms3188 KiB
9Accepted4/46ms3404 KiB
10Accepted4/48ms3744 KiB
11Accepted4/48ms3948 KiB
12Accepted4/46ms3772 KiB
13Accepted4/48ms4184 KiB
14Accepted4/48ms4140 KiB
15Accepted4/48ms4352 KiB
16Accepted4/48ms4560 KiB
17Accepted4/48ms4988 KiB
18Accepted4/48ms4592 KiB
19Accepted2/23ms4264 KiB
20Accepted2/23ms4484 KiB
21Accepted3/33ms4376 KiB
22Accepted3/33ms4404 KiB
23Accepted3/38ms5264 KiB
24Accepted3/38ms5268 KiB