백준
[백준] 14467번 소가 길을 건너간 이유 1 (java, 구현)
해랑쓰
2021. 4. 29. 17:28
728x90
반응형
import java.util.Arrays;
import java.util.Scanner;
public class B_14467_소가길을건너간이유1_Main {
static int n;
static int[] cow;
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int answer=0;
n=sc.nextInt();
cow=new int[11];
Arrays.fill(cow, -1);
for (int i = 0; i < n; i++) {
int num=sc.nextInt();
int pos=sc.nextInt();
if(cow[num]==-1) {
cow[num]=pos;
}else if(cow[num]!=pos) {
cow[num]=pos;
answer+=1;
}
}
System.out.println(answer);
}
}
728x90
반응형