-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathQueue.java
More file actions
55 lines (50 loc) · 1.7 KB
/
Copy pathQueue.java
File metadata and controls
55 lines (50 loc) · 1.7 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package queue;
import java.util.*;
import java.io.*;
public class Queue {
private static int peopleInQueue;
private static String result;
private static void getData() throws IOException{ // Получение данных
FileReader file = new FileReader("input.txt");
Scanner sc = new Scanner(file);
peopleInQueue = sc.nextInt();
}
private static void timeInQueue(){ // Расчет времени в очереди
int queue;
int hour, minute, allminute;
boolean sucsess = true;
if(peopleInQueue % 2 == 0){ // 1 очередь
queue = peopleInQueue / 2 - 1;
allminute = queue * 10;
hour = allminute / 60;
minute = allminute - hour * 60 + 5;
if(minute >= 60){
hour = hour + 1;
minute = minute + 5 - 60;
}
if(hour > 11 || (hour == 11 && minute > 55)){
sucsess = false;
}
}else{ // 2 очередь
queue = peopleInQueue / 2;
allminute = queue * 10;
hour = allminute / 60;
minute = allminute - hour * 60;
if(minute >= 60){
hour = hour + 1;
minute = minute - 60;
}
if((hour == 12 && minute !=0) || hour > 12){
sucsess = false;
}
}
result = (!sucsess) ? "NO" : hour + " " + minute; // Ответ на задачу
}
public static void main(String[] argv) throws IOException{
getData();
timeInQueue();
PrintWriter pw = new PrintWriter(new File("output.txt"));
pw.print(result);
pw.close();
}
}