fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int item[1001];
  6. int best=0,worst=2e9;
  7. int good=0,bad=0;
  8. int main() {
  9. int N,K;
  10. cin>>N>>K;
  11. for(int n=0;n<K;n++){
  12. int v;
  13. cin>>v;
  14. item[v]+=1;
  15. }
  16. for(int n=1;n<=N;n++){
  17. if(item[n]>best)
  18. best=item[n];
  19. if(item[n]!=0 && item[n]<worst)
  20. worst=item[n];
  21. }
  22. int last[N+1][1001];
  23. for(int n=1;n<=N;n++){
  24. cin>>last[n][0];
  25. }
  26. for(int n=1;n<=N;n++){
  27. for(int m=1;m<=last[n][0];m++)
  28. cin>>last[n][m];
  29. }
  30. for(int n=1;n<=N;n++){
  31. for(int m=1;m<=last[n][0];m++){
  32. if(last[n][m]==best)
  33. good=n;
  34. if(last[n][m]==worst)
  35. bad=n;
  36. }
  37. }
  38. cout<<good<<" "<<bad;
  39. }
Success #stdin #stdout 0.01s 5280KB
stdin
6 3
56 56 47 23 47 47
1 1 1
23
47
56
stdout
6 0