+ 2
Can anyone tell me why it is not passing the test cases?
import java. util.*; public class Program { public static void main(String[] args) { Scanner sc=new Scanner (System.in); ArrayList <String> n=new ArrayList <>(); String t=sc.next(); int a=sc.nextInt(); for(int i=0;i<4;i++) { n.add(sc.next()); } n.add(t); Collections.sort(n); //System.out.print(n); for(int i=0;i<n.size();i++) { if(t==n.get(i)) { System.out.println (20*(i+1)); break ; } } } }
29 ответов
+ 2
How Zeb will require 20 mins ? Can you elaborate the times of bem Bob Jan pan also? Please
+ 2
Jayakrishna🇮🇳 Oh sorry for asking codes ,is posting code coach solutions in the code playground is against the rules?
+ 2
Jayakrishna🇮🇳 Is asking doubts of it is also prohibited. I asked for 2 code coach only because I was unable to understand the question I never ask for codes
+ 2
Check out this 👇
import java.util.Scanner;
import java.util.Arrays;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String customer = input.next();
int agents = input.nextInt();
input.nextLine();
String otherCustomers = input.nextLine();
String allCustomers = otherCustomers + " " + customer;
String [] waitingList = allCustomers.split("\\s");
Arrays.sort(waitingList);
int place = 0;
for (int i=0; i<waitingList.length; i++) {
if (waitingList[i].equals(customer)){
place = i;
}
}
int time = (int)((place/agents+1)*20);
System.out.print(time);
}
}
+ 1
Jayakrishna🇮🇳 Can you please explain the number of agents stuff if you look at the first test case?
+ 1
If here the work is done with the indexing then why not in other cases?
+ 1
Did you observed that you are not using agent 'a' value anywhere.. it's the actual parameter in the problem. See for example same sample with a=5,
Zeb
5
Bob Jan Ben Pat
Here, agent =5, each one can interview a person in 20mins .. in order
" Ben Bob Jan Pan Zeb "
So Zeb is the 5th person, can get slot 1st time by 5th agent so 1*20=20mins needed for his interview completion...
Is that clears ?
+ 1
Anyone please help I am unable to get answer?
+ 1
Jayakrishna🇮🇳 you mean like this?
System.out.println (20*(i+1)/a);
+ 1
Jayakrishna🇮🇳 Not completed 2 cases
+ 1
Jayakrishna🇮🇳 Please don't provide me any code. I want to completely do it by myself
+ 1
Jayakrishna🇮🇳 in case if you can provide any other examples because the visible test cases and the example given by you works out here
+ 1
Getting answer using this
System.out.println (20*((i/a)+1));
+ 1
Jayakrishna🇮🇳 thanks for your help. Can post your Sol?
+ 1
20*(I+agents) don't fullfill the cases
+ 1
Thanks for the information Jayakrishna🇮🇳
0
i think you are counting only when Agents a = 1, but not for more agents...
For ex:
Z
4
A B C D
The output should be 40 I think. Because 4agents will test 4people in 20 mins so Person Z comes next and he comes out after 20mins so total 20+20=40mins only but code output is 100
Read again description.. hope it helps ..
0
Zeb
1
Bob Jan Ben Pat
Here, agent =1 he can interview a person 20mins .. in order
" Ben Bob Jan Pan Zeb "
So Zeb is the 5th person, can get slot 5th time so 5*20=100mins needed for his interview completion.
0
The 1st input is the person for whom we need to calculate his completion time of interview.
One agent can can interview a person in 20mins. Interview is conducted in alphabetical order. Then so total 5person came to interview. No.of Agents is input.
So first arrange all in alphabetical order and find input person completion time.
Zeb
5
Bob Jan Ben Pat
Here, agent =5, we need to find Zeb completion time.
Each one agent can interview a person in 20mins .. in order
" Ben Bob Jan Pan Zeb "
1st agent interview Ben
2nd interviews Bob
3rd interviews Jan
4th interviews Pan
5th interviews Zeb
All will be interviewed at the same time,and each takes 20mins.
So Zeb is the 5th person, can get slot 1st time by 5th agent so 20mins needed for his interview completion...
Note: there are 5 interview halls, 5 members will came for interview. If any agent can absent,then other remaining will take responsibility... (It does not mean , interviewed one after the other,they can conduct interview at simultaneously also...)
...?
0
Is that working in code coach .? .try it yourself. Are you understood the problem ? Or Do you want code solution? Its better to find yourself.