0
Why wont pass 2 tests of 5??
import java.util.*; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String myName = sc.nextLine(); int nmAgent = sc.nextInt(); sc.nextLine(); String candi = sc.nextLine(); String[] clients = candi.split(" "); ArrayList<String> people = new ArrayList<String>(); for(int i = 0; i < clients.length; i++){ people.add(clients[i]); } people.add(myName); Collections.sort(people); int myI =(people.indexOf(myName)); int myTot = (int)Math.ceil((1 + myI)/ nmAgent); if(nmAgent > 1){ System.out.print(20 * myTot); } else if(nmAgent < 2){ System.out.print(((myI + 1) * 20) / nmAgent); } } }
8 Réponses
0
If u calculate formula its what task is asking but still wont pass. What did i miss here 🤔
0
For the case: myl=0, first place according to your code, and nmagents=5
It returns 0.
0
if(myI == 0 && nmAgent > 1){
myI = 1;
}
0
That doesnot fit for other cases..
Did you checked it..?
Try to for other possible cases in code playground..
When person is in first or second place, and number of agents or 3 or 4 or 5, it is incorrect result 0.
I didn't checked all,.. But a sample cases it returning zero so try it again..
0
Yes i see. Thank you
0
JayaKrishna how you know what is test asking if its hidden? It would be much better to see what test is asking or description should tell you about conditions. Then you know what task is asking from you.
0
I don't understand your reply clearly.. But if you are asking how to check is run it in playground.. Description says person may in 1 to 5 positions and number of agents are 1 to 5. So by these info we can check Program correctness, by inputing possible cases...
Task is to write to satisfy all possible cases..
Your question is why not passing 2 out 5. So I checked it by sample cases and give a replys.. So.
Test cases must be hidden otherwise one can easily hardcode solution for test cases..
Edit:
Are you asking write solution?
0
Ok thank you