CODEFORCES 390A

CODEFORCES 

390A - Inna and Alarm Clock

Link to Ques - Codeforces 390A



 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
import java.util.Arrays;
import java.util.Scanner;

public class CF390A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int visx[] = new int[110];
        int visy[] = new int[110];

        Arrays.fill(visx,0);
        Arrays.fill(visy,0);

        int n = sc.nextInt();
        for(int i=0;i<n;i++)
        {
            int x = sc.nextInt();
            int y = sc.nextInt();

            visx[x]=1;
            visy[y]=1;
        }
        int cx=0,cy=0;
        for(int i=0;i<110;i++)
        {
            if(visx[i]==1)
                cx++;
            if(visy[i]==1)
                cy++;
        }

        System.out.println(Math.min(cx,cy));
    }
}

Comments

Popular posts from this blog

Class 12 Chemistry Practicals

Class 12 Physics Practicals