Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication5;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.LinkedHashSet;
- import java.util.List;
- import java.util.Set;
- /**
- *
- * @author HoangLong
- */
- public class JavaApplication5 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws IOException {
- // 自分の得意な言語で
- // Let's チャレンジ!!
- Set<Integer> XSet = new LinkedHashSet<>();
- Set<Integer> YSet = new LinkedHashSet<>();;
- String[] strArray;
- int[] intArray;
- String line;
- int i;
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- line = br.readLine();
- strArray = line.split(" ");
- intArray = new int[strArray.length];
- for (i = 0; i < strArray.length; i++) {
- intArray[i] = Integer.parseInt(strArray[i]);
- }
- int x = intArray[0];
- int y = intArray[1];
- int z = intArray[2];
- int n = intArray[3];
- XSet.add(0);
- XSet.add(x);
- YSet.add(0);
- YSet.add(y);
- for (i = 0; i < n; i++){
- line = br.readLine();
- strArray = line.split(" ");
- intArray = new int[strArray.length];
- for (int j = 0; j < strArray.length; j++) {
- intArray[j] = Integer.parseInt(strArray[j]);
- }
- int direction = intArray[0];
- int value = intArray[1];
- if (direction == 0) {
- XSet.add(value);
- } else {
- YSet.add(value);
- }
- }
- List<Integer> XList = new ArrayList<Integer>(XSet);
- List<Integer> YList = new ArrayList<Integer>(YSet);
- Collections.sort(XList);
- Collections.sort(YList);
- int resultX = x;
- int resultY = y;
- for (i = 0; i < XList.size() - 1; i++) {
- int distance = XList.get(i + 1) - XList.get(i);
- if (distance < resultX) {
- resultX = distance;
- }
- }
- for (i = 0; i < YList.size() - 1; i++) {
- int distance = YList.get(i + 1) - YList.get(i);
- if (distance < resultY) {
- resultY = distance;
- }
- }
- int result = resultX * resultY * z;
- System.out.println(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement