152A - Marks - CodeForces Solution


implementation *900

Please click on ads to support us..

Python Code:

n,m = map(int,input().split())
l = []
bk = 0
for i in range(n):
	z = input().strip()
	k = "".join(z)
	l.append(k)
	c = ("".join(l))
	k = str(c)
	
v = []
t = 0
i = 0
while i<m:
  c = k[i::m]
  i+=1
  v.append((c))
r = [int(i) for i in v]
f = []
if n == 1:
	print(n)
else:
	c = 0
	for i in v:
	  l = " ".join(i)
	  x = l.split()
	  	  sd = [int(i) for i in x]
	  	  k = set(sd)
	  if len(k)==1:
	  		  	c +=n
	  	bk += 1
	  	break
	  else:
		  cv = list(sd)

		  s = max(cv)
		  index = [i for i in range(len(cv))if cv[i] == s]
		  		  for x in range(len(index)):

		  	f.append(index[x])

		  c+=0
pr = set(f)
if n!=1:
	p = (len(pr))
	if bk==1:
		print(c)
	else:
		print(p+c)












C++ Code:

#include<iostream>
#include<bits/stdc++.h>
#define el endl
#define ll long long
#define du double
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false),cout.tie(NULL),cin.tie(NULL);
#define Omar_Ahmed_O_H_M codeforce
const int N = 1e9 + 5;
using namespace std;
int main(){
	int n,m,c=0;
	cin>>n>>m;
	string a[n];
	int x[n]={0};
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	
	for(int j=0;j<m;j++)
	{
		int mx=0;
		for(int i=0;i<n;i++)
		{
			
			if(a[i][j]>mx)
			{
				mx=a[i][j];
			}
			
		}
		for(int i=0;i<n;i++)
			{
				if(a[i][j]==mx)
				{
					x[i]=1;
					
				}
			}
	}
	
for(int i=0;i<n;i++)
{
	if(x[i]==1)
	c++;
}
cout<<c;
}


Comments

Submit
0 Comments
More Questions

1395A - Boboniu Likes to Color Balls
1637C - Andrew and Stones
1334B - Middle Class
260C - Balls and Boxes
1554A - Cherry
11B - Jumping Jack
716A - Crazy Computer
644A - Parliament of Berland
1657C - Bracket Sequence Deletion
1657B - XY Sequence
1009A - Game Shopping
1657A - Integer Moves
230B - T-primes
630A - Again Twenty Five
1234D - Distinct Characters Queries
1183A - Nearest Interesting Number
1009E - Intercity Travelling
1637B - MEX and Array
224A - Parallelepiped
964A - Splits
1615A - Closing The Gap
4C - Registration System
1321A - Contest for Robots
1451A - Subtract or Divide
1B - Spreadsheet
1177A - Digits Sequence (Easy Edition)
1579A - Casimir's String Solitaire
287B - Pipeline
510A - Fox And Snake
1520B - Ordinary Numbers