-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA3activity.java
More file actions
53 lines (51 loc) · 1.18 KB
/
A3activity.java
File metadata and controls
53 lines (51 loc) · 1.18 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
import java.util.*;
public class A3activity
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] s=new int[n];
int[] f=new int[n];
int[] a=new int[n];
for(int i=0;i<n;i++)
{
s[i]=sc.nextInt();
}
for(int i=0;i<n;i++)
{
f[i]=sc.nextInt();
}
for(int i=0;i<n;i++)
{
a[i]=i+1;
}
int swap,swap1,swap2;
for (int i=0;i<n-1;i++)
{
for (int j=0;j<n-i-1;j++)
{
if (f[j]>f[j+1])
{
swap = f[j];
f[j] = f[j+1];
f[j+1] = swap;
swap1 = s[j];
s[j] = s[j+1];
s[j+1] = swap1;
swap2 = a[j];
a[j] = a[j+1];
a[j+1] = swap2;
}
}
}
int i=0;
System.out.print(a[0]+"\t");
for(int j=1;j<n;j++)
{
if(s[j]>=f[i])
System.out.print(a[j]);
i=j;
}
}
}