시간초과 에러
259
이혜정
작성한 질문수 7
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int headCnt = sc.nextInt();
int testCnt = sc.nextInt();
int[][] array = new int[testCnt][headCnt];
for(int i=0; i<testCnt; i++) {
for(int j=0; j<headCnt; j++) {
array[i][j] = sc.nextInt();
}
}
System.out.print(solution(headCnt, testCnt, array));
}
public static int solution(int headCnt, int testCnt, int[][] arr) {
int answer = 0;
for(int i=1; i<=headCnt; i++) {
for(int j=1; i<=headCnt; j++) {
int cnt=0;
for(int k=0; k<testCnt; k++) {
int pi = 0, pj = 0;
for(int s=0; s<headCnt; s++) { //등수
if(arr[k][s] == i) pi = s;
if(arr[k][s] == j) pj = s;
}
if(pi < pj) cnt++;
}
if(cnt == testCnt) {
answer++;
}
}
}
return answer;
}
}왜 에러가 나는지 잘 모르겠습니다
답변 1
안녕하세요. 바뀐 채점사이트 관련해서 문의드립니다.
1
83
3
갑자기 채점 사이트가 바뀌었어요
0
56
1
문제 리스트 페이지
0
44
1
채점 사이트 관련 질문드립니다
0
42
1
봉우리 문제 질문입니다
0
103
2
씨름 선수 문제에서 각 선수의 몸무게나 키가 같을 수도 있다면?
0
75
0
이 코드랑 영상 코드중에 뭐가 더 좋은 코드인가요?
0
83
0
가중치 방향 그래프에서 가중치가 0인 간선을 표현하는 방법
0
77
1
좌표 정렬 문제 이 코드가 왜 틀린지 모르겠습니다 ㅠㅠ
0
96
2
6-7 강의에서
0
56
1
6-6. 장난꾸러기 질문 있습니다.
0
54
1
강의 수강후 코딩테스트
0
127
1
answer 변수 사용 여부
0
51
1
2중 for문
1
98
2
2-11. 임시반장정하기 (Runtime Error)
0
69
1
혹시 LinkedList 같은 자료 구조들은 따로 배우지 않나요?
0
76
1
이런 풀이는 어떨까요
0
52
1
자바 스트림 방식의 효율성 질문 드립니다.
0
63
1
알고리즘 자료 구조들..
0
69
1
StringBuilder vs BufferdWriter
0
53
1
원더랜드(프림)
0
58
1
이런 코드는 어떤가요?
0
68
1
bfs 풀이
0
65
1
병합정렬
0
58
1





