Skip to content
Merged

. #20

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions 이지수/SWEA/D2/1204.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.util.Scanner;

class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();

for(int test_case = 1; test_case <= T; test_case++)
{
sc.nextInt();

int[] scores = new int[101];
for(int i = 0; i < 1000; i++){
scores[sc.nextInt()]++;
}

int[] result = {-1, 0};
for(int i = 0; i < 101; i++) {
if(scores[i] > result[1] || (scores[i] == result[1] && i > result[0])) {
result[0] = i;
result[1] = scores[i];
}
}
System.out.println("#" + test_case + " " + result[0]);
}
}
}
51 changes: 51 additions & 0 deletions 이지수/SWEA/D2/12712. 파리퇴치3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import java.util.Scanner;

class Solution {
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();

for(int test_case = 1; test_case <= T; test_case++) {
int N = sc.nextInt();
int M = sc.nextInt();

int[][] flies = new int[N][N];
for(int i = 0; i < N; i++)
for(int j = 0; j < N; j++)
flies[i][j] = sc.nextInt();

int max = 0;
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++) {
int sum1 = flies[i][j];
int sum2 = flies[i][j];
for(int x = 1; x < M; x++) {
if(j - x >= 0)
sum1 += flies[i][j - x];
if(j + x < N)
sum1 += flies[i][j + x];
if(i - x >= 0)
sum1 += flies[i - x][j];
if(i + x < N)
sum1 += flies[i + x][j];

if(i - x >= 0 && j - x >= 0)
sum2 += flies[i - x][j - x];
if(i + x < N && j + x < N)
sum2 += flies[i + x][j + x];
if(i - x >= 0 && j + x < N)
sum2 += flies[i - x][j + x];
if(i + x < N && j - x >= 0)
sum2 += flies[i + x][j - x];
}

int tmp = sum1 > sum2 ? sum1 : sum2;
if(max < tmp)
max = tmp;
}
}

System.out.println("#" + test_case + " " + max);
}
}
}
35 changes: 35 additions & 0 deletions 이지수/SWEA/D2/1859. 백만 장자 프로젝트.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import java.util.Scanner;

class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();

for(int test_case = 1; test_case <= T; test_case++)
{
int N = sc.nextInt();
int[] prices = new int[N];
for(int i = 0; i < N; i++) {
prices[i] = sc.nextInt();
}

int result = 0;
int idx = -1;
while(idx < N) {
int max = -1;
for(int i = idx + 1; i < prices.length; i++) {
if(prices[i] >= max) {
max = prices[i];
idx = i;
}
}
for(int i = 0; i < idx; i++) {
result += max - prices[i];
}
}
System.out.println("#" + test_case + " " + result);
}
}
}
32 changes: 32 additions & 0 deletions 이지수/SWEA/D2/1940. 가랏! RC카!.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.util.Scanner;

class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();

for(int test_case = 1; test_case <= T; test_case++)
{
int N = sc.nextInt();
int v = 0;
int d = 0;
for(int i = 0; i < N; i++){
int command = sc.nextInt();
if(command == 0)
d += v;
else if(command == 1) {
v += sc.nextInt();
d += v;
}
else {
int a = sc.nextInt();
v = (v - a >= 0? v - a : 0);
d += v;
}
}
System.out.println("#" + test_case + " " + d);
}
}
}
42 changes: 42 additions & 0 deletions 이지수/SWEA/D2/1954. 달팽이 숫자.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import java.util.Scanner;

class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();

for(int test_case = 1; test_case <= T; test_case++)
{
int N = sc.nextInt();
int arr[][] = new int[N][N];

int[] dx = {0, 1, 0, -1};
int[] dy = {1, 0, -1, 0};
int dirIdx = 0;

int cnt = 1;

int r = 0;
int c = 0;

while(cnt <= N * N){
if(r + dx[dirIdx] >= N || r + dx[dirIdx] < 0 || c + dy[dirIdx] >= N || c + dy[dirIdx] < 0 || arr[r + dx[dirIdx]][c + dy[dirIdx]] != 0)
dirIdx = (dirIdx + 1) % 4;
arr[r][c] = cnt;
r += dx[dirIdx];
c += dy[dirIdx];
cnt++;
}

System.out.println("#" + test_case);
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++) {
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}
}