Mr. Myers and the Exam
A mathematics question paper has certain number of questions and each
question is assigned some random maximum marks. Mr. Myers wants to edit
the marks assigned to the questions such that:
1. All questions in the paper should have distinct maximum marks.
2. The total marks of all the question should be as low as possible.
Mr. Myers wants to achieve this by making minimal changes in the original
format, assigning the question at least as much marks as it originally had. Find
the minimum total marks that he can set the paper for
Input Specification:
input1: The number of questions in the paper
input2: The array representing the original marks assigned to every question
Output Specification:
Answers
Answered by
16
Answer:
Explanation:
public static int minimal(int n,int[] arr)
{
int sum=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(arr[i]==arr[j])
{
int[] count = new int[]{1};
arr[i]=arr[i]+count[0];
}
}
}
for(int i=0;i<n;i++)
{
sum=sum+arr[i];
}
return sum;
}
this is a java program which can solve this question.
#SPJ3
Answered by
15
Answer:
def optimized_marks(input):
for i in range(0,len(input)):
for j in range (i+1,len(input)):
if input[i]==input[j]:
input[j]=input[j]+1
return sum(input)
Explanation:
Similar questions