Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Solution {
- public static void main(String[] args) {
- /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
- int n,c,u,s;
- Scanner sc=new Scanner(System.in);
- n=sc.nextInt();
- c=sc.nextInt();
- u=sc.nextInt();
- s=sc.nextInt();
- System.out.println(getMaxPlayers(n,c,u,s));
- }
- static int getMaxPlayers(int n,int c,int u,int s){
- int m=0;
- int i;
- int currentc=c;
- int t;
- if (c>=n*u) return n;
- for(t=0;t<=n;t++){
- if(s*t+c<=(n-t)*u) return (n-t);
- }
- return t;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement