Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Solution {
  5.  
  6. public static void main(String[] args) {
  7. /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
  8. int n,c,u,s;
  9. Scanner sc=new Scanner(System.in);
  10. n=sc.nextInt();
  11. c=sc.nextInt();
  12. u=sc.nextInt();
  13. s=sc.nextInt();
  14.  
  15. System.out.println(getMaxPlayers(n,c,u,s));
  16.  
  17. }
  18.  
  19. static int getMaxPlayers(int n,int c,int u,int s){
  20. int m=0;
  21. int i;
  22. int currentc=c;
  23. int t;
  24. if (c>=n*u) return n;
  25. for(t=0;t<=n;t++){
  26. if(s*t+c<=(n-t)*u) return (n-t);
  27. }
  28. return t;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement