Skip to content

Instantly share code, notes, and snippets.

@jutikorn
Created March 26, 2017 17:30
Show Gist options
  • Save jutikorn/86245e17101212d793101c0faad9900b to your computer and use it in GitHub Desktop.
Save jutikorn/86245e17101212d793101c0faad9900b to your computer and use it in GitHub Desktop.
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