Cod sursa(job #1711211)

Utilizator ariel_roAriel Chelsau ariel_ro Data 30 mai 2016 20:16:29
Problema Carte2 Scor 100
Compilator java Status done
Runda Arhiva ICPC Marime 1.26 kb
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner reader = new Scanner(new FileInputStream("carte2.in"));
		PrintWriter writer = new PrintWriter("carte2.out");
		int n = reader.nextInt();

		for (int i = 1; i <= n; i++) {
			int a = reader.nextInt();
			int b = reader.nextInt();
			int c = reader.nextInt();
			int d = reader.nextInt();
			int e = reader.nextInt();

			int[] dimBook = { a, b };
			Arrays.sort(dimBook);
			int[] dimBox = { c, d, e };
			Arrays.sort(dimBox);
			
			int pos1 = -1;
			if (dimBox[0] > dimBook[0]) {
				pos1 = 0;
			} else if (dimBox[1] > dimBook[0]) {
				pos1 = 1;
			} else if (dimBox[2] > dimBook[0]) {
				pos1 = 2;
			}
			
			if (pos1 == 2 || pos1 == -1) {
				writer.append("imposibil\n");
			} else {
				if (pos1 == 0) {
					if (dimBox[1] > dimBook[1] || dimBox[2] > dimBook[1]) {
						writer.append("posibil\n");
					} else {
						writer.append("imposibil\n");
					}
				} else if (pos1 == 1) {
					if (dimBox[2] > dimBook[1]) {
						writer.append("posibil\n");
					} else {
						writer.append("imposibil\n");
					}
				}
 			}
		}
		writer.close();
		reader.close();
	}

}