시간초과 에러
261
이혜정
작성한 질문수 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
148
3
갑자기 채점 사이트가 바뀌었어요
0
81
1
문제 리스트 페이지
0
82
1
채점 사이트 관련 질문드립니다
0
66
1
봉우리 문제 질문입니다
0
131
2
씨름 선수 문제에서 각 선수의 몸무게나 키가 같을 수도 있다면?
0
89
0
이 코드랑 영상 코드중에 뭐가 더 좋은 코드인가요?
0
94
0
가중치 방향 그래프에서 가중치가 0인 간선을 표현하는 방법
0
110
1
좌표 정렬 문제 이 코드가 왜 틀린지 모르겠습니다 ㅠㅠ
0
120
2
6-7 강의에서
0
76
1
6-6. 장난꾸러기 질문 있습니다.
0
70
1
강의 수강후 코딩테스트
0
150
1
answer 변수 사용 여부
0
70
1
2중 for문
1
122
2
2-11. 임시반장정하기 (Runtime Error)
0
89
1
혹시 LinkedList 같은 자료 구조들은 따로 배우지 않나요?
0
99
1
이런 풀이는 어떨까요
0
75
1
자바 스트림 방식의 효율성 질문 드립니다.
0
86
1
알고리즘 자료 구조들..
0
91
1
StringBuilder vs BufferdWriter
0
71
1
원더랜드(프림)
0
74
1
이런 코드는 어떤가요?
0
88
1
bfs 풀이
0
84
1
병합정렬
0
84
1





