22022023-01-02 13:59:34zalan0323Kert (75 pont)cpp11Accepted 75/75239ms13004 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
#include <climits>
#include <vector>
#define ll long long
using namespace std;

int main() {
	int m, n, p;
	cin >> m >> n >> p;
	vector<vector<ll>> sokszam(m);
	for(int i = 0; i<m; i++){
		for(int j = 0; j<n; j++){
			int x;
			cin >> x;
			sokszam[i].push_back(x);
		}
	}
	//számok egymás mellett
    int maxi = 1;
	for(int i = 0; i<m; i++){
		int szamlalo = 1;
		for(int j = 0; j<n-1; j++){
			if(sokszam[i][j]==sokszam[i][j+1]){
				szamlalo++;
			}else{
				szamlalo=1;
			}
			if(maxi<szamlalo){
				maxi=szamlalo;
			}
		}
	}
	//többség
	for(int i = 0; i<m;i++){
		sort(sokszam[i].begin(), sokszam[i].end());
	}
	
	int tobbsegszama = 0;
	for(int i = 0; i<m; i++){
		int szamlalo = 1;
		for(int j = 0; j<n-1; j++){
			if(sokszam[i][j]==sokszam[i][j+1]){
				szamlalo++;
			}else{
				if(szamlalo>n/2){
					tobbsegszama++;
					//cout << szamlalo << " " << tobbsegszama << endl << endl;
				}
				szamlalo=1;
			}
		}
		if(szamlalo>n/2){
			tobbsegszama++;
			//cout << szamlalo << " " << tobbsegszama << endl << endl;
		}
	}

	//kimenet
	cout << tobbsegszama << endl;
	cout << maxi << endl;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1812 KiB
2Accepted0/0224ms10296 KiB
3Accepted4/42ms2108 KiB
4Accepted4/42ms2304 KiB
5Accepted4/42ms2512 KiB
6Accepted4/42ms2592 KiB
7Accepted4/42ms2736 KiB
8Accepted4/42ms3084 KiB
9Accepted4/42ms3028 KiB
10Accepted4/46ms3464 KiB
11Accepted6/63ms3472 KiB
12Accepted6/610ms3920 KiB
13Accepted6/627ms4840 KiB
14Accepted6/6209ms12144 KiB
15Accepted6/6209ms13004 KiB
16Accepted6/6239ms12108 KiB
17Accepted7/7120ms8224 KiB