You are not logged in. Please login at www.codechef.com to post your questions!

×

Codeforces Problem 758C Help

Problem
Editorial

Someone Please explain me the editorial as I am unable to understand the logic.

Thanks in Advance :)

asked 22 Feb '17, 12:55

deepansh_946's gravatar image

2★deepansh_946
466
accept rate: 0%


Chef will start asking from students from 1st row to nth row and then from (n-1)th row to 2nd row. This constitutes 1 time period lets say. Thus, after every time period, chef will ask 1st row 1st student.

In one time period except 1st and last row students, other students are asked 2 questions while former have been asked 1 question.Thus no. of questions asked in 1 period is T=nm+(n-2)m. Left out question is k%T.

Now remaining questions are asked starting from 1st row 1st student.

Now let f(x,y) denotes no. of questions asked to xth row yth column student

no of periods,nt=k/T

remaining = k%T

f(1,y)=f(n,y)=nt

f(x,y)=2*nt x>1&&x<n

for (i = 0; k > 0 && i < n; i++)

for (j = 0; j < m && k > 0; j++) {

f(i,j)++;

k--; }

Now simply iterate over all possible n,m and find max,min and questions asked to Sergei

Complexity O(n*m)

Hope it helps. In case of any doubt, you can comment.

link

answered 25 Feb '17, 01:08

inovation123's gravatar image

4★inovation123
4537
accept rate: 10%

edited 02 Mar '17, 17:26

link

answered 02 Mar '17, 17:37

aminuteman's gravatar image

1★aminuteman
1745
accept rate: 13%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×688

question asked: 22 Feb '17, 12:55

question was seen: 448 times

last updated: 02 Mar '17, 17:37