22032023-01-02 13:59:44zalan0323Kert (75 pont)cpp11Accepted 75/75243ms12616 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/03ms1808 KiB
2Accepted0/0233ms10300 KiB
3Accepted4/42ms2260 KiB
4Accepted4/42ms2476 KiB
5Accepted4/42ms2488 KiB
6Accepted4/42ms2616 KiB
7Accepted4/42ms2696 KiB
8Accepted4/42ms2836 KiB
9Accepted4/42ms2952 KiB
10Accepted4/46ms3280 KiB
11Accepted6/63ms3260 KiB
12Accepted6/69ms3592 KiB
13Accepted6/627ms4388 KiB
14Accepted6/6209ms11720 KiB
15Accepted6/6209ms12616 KiB
16Accepted6/6243ms11712 KiB
17Accepted7/7122ms8152 KiB