Algorithm


Problem Name: 2 AD-HOC - beecrowd | 1794 | [PJ]

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1794

Laundry

 

By Cristhian Bonilha, UTFPR BR Brazil

Timelimit: 1

Tired of washing your dirty clothes, your mother decided that, for now on, who washes your clothes is you.

On the laundry room of your home there is a washer and a dryer, each with its own limits of minimum and maximum amount of clothes to be washed and dried per time. Therefore, the washer can only be used if you put at least LA and at most LB clothes inside it, and similarly the dryer can only be used if you put at least SA and at most SB clothes inside it.

You currently have N clothes to be washed and dried, and you want to find out if it is possible to use the washer and dryer to wash and dry all of your clothes, following the rules described above.

 

Input

 

On the first line of input there is an integer N (1 ≤ N ≤ 100).

On the second line of input there are two integers LA and LB (1 ≤ LA < LB ≤ 100).

On the third line of input there are two integers SA and SB (1 ≤ SA < SB ≤ 100).

 

Output

 

Print the word "possivel" if it is possible to wash and dry all of your clothes following the rules described on the statement, or "impossivel" otherwise.

 

 

 

Input Samples Output Samples

10
8 12
10 14

possivel

 

 

 

12
10 11
12 16

impossivel

 

 

 

20
10 20
20 30

possivel

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main(void) {
   int n, la, lb;

   scanf("%d", &n);
   scanf("%d %d", &la, &lb);

   if (la  < = n && n <= lb) {
      scanf("%d %d", &la, &lb);
      if (la <= n && n <= lb)
         printf("possivel");
      else printf("impossivel");
   }
   else {
      scanf("%d %d", &la, &lb);
      printf("impossivel");
   }
   printf("\n");
   return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
10
8 12
10 14

Output

x
+
cmd
possivel

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>

using namespace std;

int main(void) {
   int n, la, lb;

   cin >> n;
   cin >> la >> lb;

   if (la  < = n and n <= lb) {
      cin >> la >> lb;
      if (la  < = n and n <= lb)
         cout << "possivel";
      else cout << "impossivel";
   }
   else {
      cin >> la >> lb;
      cout << "impossivel";
   }
   cout << endl;
   return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
10
8 12
10 14

Output

x
+
cmd
possivel

#3 Code Example with Java Programming

Code - Java Programming


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static Reader in = new Reader(System.in);
    static Writer out = new Writer(System.out);

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        int LA = in.nextInt();
        int LB = in.nextInt();
        int SA = in.nextInt();
        int SB = in.nextInt();
        boolean f = LA  < = N && N <= LB && SA <= N && N <= SB;
        out.println(f ? "possivel": "impossivel" );
        in.close();
        out.flush();
        out.close();
    }

    static class Reader implements Closeable {

        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public Reader(InputStream input) {
            reader = new BufferedReader(
                    new InputStreamReader(input));
            tokenizer = new StringTokenizer("");
        }

        private StringTokenizer getTokenizer() throws IOException {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                String line = nextLine();
                if (line == null) {
                    return null;
                }
                tokenizer = new StringTokenizer(line);
            }
            return tokenizer;
        }

        public boolean hasNext() throws IOException {
            return getTokenizer() != null;
        }

        public String next() throws IOException {
            return hasNext() ? tokenizer.nextToken() : null;
        }

        public String nextLine() throws IOException {
            tokenizer = null;
            return reader.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public float nextFloat() throws IOException {
            return Float.parseFloat(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public String[] nextStringArray(int size) throws IOException {
            String[] array = new String[size];
            for (int i = 0; i  <  size; i++) {
                array[i] = next();
            }
            return array;
        }

        public int[] nextIntArray(int size) throws IOException {
            int[] array = new int[size];
            for (int i = 0; i  <  size; i++) {
                array[i] = nextInt();
            }
            return array;
        }

        public long[] nextLongArray(int size) throws IOException {
            long[] array = new long[size];
            for (int i = 0; i  <  size; i++) {
                array[i] = nextLong();
            }
            return array;
        }

        public double[] nextDoubleArray(int size) throws IOException {
            double[] array = new double[size];
            for (int i = 0; i  <  size; i++) {
                array[i] = nextDouble();
            }
            return array;
        }

        @Override
        public void close() throws IOException {
            tokenizer = null;
            reader.close();
        }
    }

    static class Writer {

        private final PrintWriter writer;

        public Writer(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public void print(Object... objects) {
            for (int i = 0; i  <  objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }

    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
10
8 12
10 14

Output

x
+
cmd
possivel

#4 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("node:fs")
const [N, LA, LB, SA, SB] = readFileSync("/dev/stdin", "utf8")
	.split(/\s+/, 5)
	.map((value) => Number.parseInt(value, 10))

console.log(
	N >= Math.max(LA, SA) && N <= Math.min(LB, SB) ? "possivel" : "impossivel"
)
Copy The Code & Try With Live Editor

Input

x
+
cmd
10
8 12
10 14

Output

x
+
cmd
possivel

#5 Code Example with Python Programming

Code - Python Programming


n = int(input())
e = str(input()).split()
la = int(e[0])
lb = int(e[1])
if la <= n <= lb:
    e = str(input()).split()
    la = int(e[0])
    lb = int(e[1])
    if la <= n <= lb: print('possivel')
    else: print('impossivel')
else:
    input()
    print('impossivel')
Copy The Code & Try With Live Editor

Input

x
+
cmd
10
8 12
10 14

Output

x
+
cmd
possivel
Advertisements

Demonstration


Previous
#1793 Beecrowd Online Judge Solution 1793 Escalator Solution in C, C++, Java, Js and Python
Next
#1796 Beecrowd Online Judge Solution 1796 Brazilian Economy Solution in C, C++, Java, Js and Python