-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfcfs.java
35 lines (34 loc) · 933 Bytes
/
fcfs.java
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
import java.util.Map;
import java.util.Scanner;
public class fcfs {
public static void main(String[] args) {
int p;
System.out.println("processes ");
Scanner sc = new Scanner(System.in);
p = sc.nextInt();
System.out.println("at\t");
int at[] = new int[p];
int bt[]=new int[p];
int ct[]=new int[p];
int tat[]=new int[p];
int wt[]=new int[p];
for(int i=0;i<p;++i){
at[i]=sc.nextInt();
bt[i]=sc.nextInt();
}
for(int i=0;i<p;++i){
if(i==0){
ct[i]=bt[i];
}else{
if(at[i]<=ct[i-1]){
ct[i]=ct[i-1]+bt[i];
}else{
ct[i]=at[i]+bt[i];
}
}
}
for(int i=0;i<p;++i){
System.out.println(ct[i]);
}
}
}