The manager is really disappointed when he sees that all his employees have become lazy AF. Hence, he decides to encourage his employees by holding a competition. This competition will go on for N days and there are a total of M employees such that : - The employee ID starts from 1. - The maximum ID possible is M. - No two employees have the same ID. - The ID of each and every employee is a positive integer. On each day of the competition, an "Employee of the Day"title is awarded to the employee who does the most work on that particular day and is given a party. However, the manager believes in consistency. Once this title has been given, the employee who has won the most number of such titles until that particular moment is presented with a "Consistency Trophy". If there are many such employees, the largest ID among them is given the trophy. The "Title Giving"and "Trophy Giving"happens at the end of each day of the competition.
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Random random = new Random();
System.out.println("N:");
int n = in.nextInt();
System.out.println("M:");
int m = in.nextInt();
//column 0 - employee of the day; 1 - consistency
int[][] rewards = new int[m + 1][2];
int[] works = new int[m + 1];
int max;
int employeeID;
for (int i = 0; i < n; i++) {
max = 0;
employeeID = 0;
for (int j = 1; j < works.length; j++) {
works[j] = random.nextInt(100) + 1;
if (works[j] >= max) {
employeeID = j;
max = works[j];
}
}
rewards[employeeID][0]++;
max = 0;
employeeID = 0;
for (int j = 1; j < rewards.length; j++) {
if (rewards[j][0] >= max) {
employeeID = j;
max = rewards[j][0];
}
}
rewards[employeeID][1]++;
}
}
}
Comments
Leave a comment