/BOJ2875.java Secret
Created
December 24, 2020 08:40
BOJ2875
This file contains hidden or 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.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
public class BOJ2875 { | |
public static void main(String[] args) throws IOException{ | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
String str[] = br.readLine().split(" "); | |
int n = Integer.parseInt(str[0]); | |
int m = Integer.parseInt(str[1]); | |
int k = Integer.parseInt(str[2]); | |
int result = 0; | |
for(int i = 0; i <= k; i++) { | |
if(0 <= m-k+i && 0 <= n-i && 2*(m-k+i) <= n-i) { | |
result = Math.max(result, m-k+i); | |
} | |
if(0 <= m-k+i && 0 <= n-i && (n-i)/2 <= m-k+i) { | |
result = Math.max(result, (n-i)/2); | |
} | |
} | |
System.out.println(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment