1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package greedy;
 
 
public class Main2875_대회or인턴 {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine(), " ");
        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());
        if (K == 0) {
            process(N, M);
        } else {
            while (K != 0) {
                if (N >= 2 * M) {
                    N--;
                    K--;
                }else {
                    M--;
                    K--;
                }
            }
            
            process(N, M);
        }
    }// end of main
    
    public static void process(int N , int M) {
        if (N >= 2 * M) {
            System.out.println(M);
            return;
        } else {
            System.out.println(N / 2);
            return;
        }
    }
}// end of class
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none; color:white">cs

+ Recent posts