Created
March 26, 2017 17:30
-
-
Save jutikorn/86245e17101212d793101c0faad9900b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class Solution { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int n = in.nextInt(); | |
int p = in.nextInt(); | |
// your code goes here | |
int maxtime = n/2; | |
int usedtime = p/2; | |
if(p <=1 || p == n){ | |
System.out.println(0); | |
}else if(usedtime > (maxtime/2)){ | |
System.out.println(maxtime - usedtime); | |
} else { | |
System.out.println(usedtime); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment