diff --git "a/\354\235\264\354\247\200\354\210\230/SWEA/D2/1204.java" "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1204.java" new file mode 100644 index 00000000..7f0b8610 --- /dev/null +++ "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1204.java" @@ -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]); + } + } +} diff --git "a/\354\235\264\354\247\200\354\210\230/SWEA/D2/12712. \355\214\214\353\246\254\355\207\264\354\271\2303.java" "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/12712. \355\214\214\353\246\254\355\207\264\354\271\2303.java" new file mode 100644 index 00000000..85143eb7 --- /dev/null +++ "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/12712. \355\214\214\353\246\254\355\207\264\354\271\2303.java" @@ -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); + } + } +} diff --git "a/\354\235\264\354\247\200\354\210\230/SWEA/D2/1859. \353\260\261\353\247\214 \354\236\245\354\236\220 \355\224\204\353\241\234\354\240\235\355\212\270.java" "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1859. \353\260\261\353\247\214 \354\236\245\354\236\220 \355\224\204\353\241\234\354\240\235\355\212\270.java" new file mode 100644 index 00000000..b4d73cea --- /dev/null +++ "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1859. \353\260\261\353\247\214 \354\236\245\354\236\220 \355\224\204\353\241\234\354\240\235\355\212\270.java" @@ -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); + } + } +} diff --git "a/\354\235\264\354\247\200\354\210\230/SWEA/D2/1940. \352\260\200\353\236\217! RC\354\271\264!.java" "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1940. \352\260\200\353\236\217! RC\354\271\264!.java" new file mode 100644 index 00000000..953047ff --- /dev/null +++ "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1940. \352\260\200\353\236\217! RC\354\271\264!.java" @@ -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); + } + } +} diff --git "a/\354\235\264\354\247\200\354\210\230/SWEA/D2/1954. \353\213\254\355\214\275\354\235\264 \354\210\253\354\236\220.java" "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1954. \353\213\254\355\214\275\354\235\264 \354\210\253\354\236\220.java" new file mode 100644 index 00000000..2122fc70 --- /dev/null +++ "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1954. \353\213\254\355\214\275\354\235\264 \354\210\253\354\236\220.java" @@ -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(); + } + } + } +}