Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 시뮬레이션
- binary search
- DP
- Java
- 백준
- 코테
- 코딩테스트
- MySQL
- 알고리즘
- math
- 운동기록
- 문제풀이
- 이분탐색
- BOJ
- BFS
- oracle
- SWEA
- priorityqueue
- 문자열
- SQL
- 문제해결
- 투포인터
- 러닝일지
- db
- 건강
- 프로그래머스
- COS PRO
- 자바
- dfs
- greedy
Archives
- Today
- Total
슈콩
[SWEA] 시험 본문


[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AW45RuSae2gDFAQ7
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[소스 코드]
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int T = Integer.parseInt(br.readLine());
for(int tc=1;tc<=T;tc++) {
st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int t = Integer.parseInt(st.nextToken());
int p = Integer.parseInt(st.nextToken());
int[][] problem = new int[n][t];
int[] score = new int[t];
for(int i=0;i<n;i++) {
st = new StringTokenizer(br.readLine());
for(int j=0;j<t;j++) {
int val = Integer.parseInt(st.nextToken());
if(val==0) {
score[j]++;
}
else problem[i][j] = 1;
}
}
int[] totalScore = new int[n];
int[] totalSolve = new int[n];
for(int i=0;i<n;i++) {
for(int j=0;j<t;j++) {
totalScore[i] += problem[i][j] * score[j];
totalSolve[i] += problem[i][j];
}
}
List<int[]> list = new LinkedList<>();
for(int i=0;i<n;i++) {
list.add(new int[] {i+1,totalScore[i],totalSolve[i]});
}
Collections.sort(list,(a,b)->{
if(a[1]==b[1]) {
if(a[2]==b[2]) {
return Integer.compare(a[0], b[0]);
}
return Integer.compare(b[2], a[2]);
}
return Integer.compare(b[1], a[1]);
});
int rank = 0;
int sum = totalScore[p-1];
for(int j=0;j<n;j++) {
if(list.get(j)[0]==p) rank = j+1;
}
System.out.println("#"+tc+" "+sum+" "+rank);
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 영준이와 신비한 뿔의 숲 (0) | 2025.11.17 |
|---|---|
| [SWEA] 두문자어 (0) | 2025.11.17 |
| [SWEA] 장애물 경주 난이도 (0) | 2025.11.17 |
| [SWEA] 문제 제목 붙이기 (0) | 2025.11.17 |
| [SWEA] 준홍이의 카드놀이 (0) | 2025.11.17 |