-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08a24ba
commit 214f190
Showing
7 changed files
with
306 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package BOJ.silver1; | ||
|
||
public class BOJ_1149 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package BOJ.silver2; | ||
|
||
import java.util.*; | ||
import java.io.*; | ||
|
||
public class BOJ_11051 { | ||
public static void main(String[] args) throws IOException{ | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); | ||
|
||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
|
||
int n = Integer.parseInt(st.nextToken()); | ||
int m = Integer.parseInt(st.nextToken()); | ||
|
||
int[][] c = new int[n+1][m+1]; | ||
|
||
if(n >= 2 && m >= 1) { | ||
c[2][1] = 2; //여기까지 초기화 해야 한다. | ||
} | ||
|
||
for(int i = 1; i<=n; i++) { | ||
for(int j = 0; j<= (i > m ? m : i) ; j++) { | ||
if(j == 0) { | ||
c[i][j] = 1; | ||
} | ||
|
||
if(i == j) { | ||
c[i][j] = 1; | ||
} | ||
} | ||
} | ||
|
||
//이항 계수 | ||
for(int i = 2; i<=n; i++) { | ||
for(int j = 1; j<= (i > m ? m : i); j++) { | ||
if(c[i][j] == 0) { //아직 안채워짐 | ||
c[i][j] = (c[i-1][j-1] + c[i-1][j]) % 10007; | ||
} | ||
} | ||
} | ||
bw.write(c[n][m] + "\n"); | ||
bw.flush(); | ||
br.close(); | ||
bw.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package BOJ.silver2; | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
|
||
public class BOJ_11053 { | ||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); | ||
|
||
int num = Integer.parseInt(br.readLine()); | ||
|
||
int[] ll = new int[num]; | ||
int[] length = new int[num]; | ||
int ans = 0; | ||
|
||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
for(int i = 0; i<num; i++) { | ||
ll[i] = Integer.parseInt(st.nextToken()); | ||
} | ||
|
||
length[0] = 1; | ||
|
||
for(int i = 1; i<num; i++) { | ||
int max = 0; | ||
for(int j = i-1; j>= 0; j--) { | ||
if(ll[j] < ll[i]) { | ||
max = Math.max(max, length[j]); | ||
} | ||
} | ||
length[i] = max + 1; | ||
} | ||
|
||
for(int i = 0; i<num; i++) { | ||
ans = Math.max(ans, length[i]); | ||
} | ||
|
||
bw.write(ans + "\n"); | ||
bw.flush(); | ||
bw.close(); | ||
br.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package BOJ.silver2; | ||
|
||
import java.util.*; | ||
import java.io.*; | ||
|
||
public class BOJ_11055_for { | ||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); | ||
|
||
int num = Integer.parseInt(br.readLine()); | ||
int[] ll = new int[num]; | ||
int[] sum = new int[num]; | ||
int ans = 0; | ||
|
||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
for(int i = 0; i<num; i++) { | ||
ll[i] = Integer.parseInt(st.nextToken()); | ||
} | ||
|
||
sum[0] = ll[0]; //초기값 | ||
|
||
for(int i = 1; i<num; i++) { | ||
int max = 0; | ||
for(int j = i-1; j>=0; j--) { | ||
if(ll[i] > ll[j]) { //ll[j]가 더 작음 | ||
max = Math.max(max, sum[j]); | ||
} | ||
} | ||
sum[i] = max + ll[i]; | ||
} | ||
|
||
for(int i = 0; i<num; i++) { | ||
ans = Math.max(ans, sum[i]); | ||
} | ||
|
||
bw.write(ans + "\n"); | ||
bw.flush(); | ||
bw.close(); | ||
br.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package BOJ.silver2; | ||
|
||
import java.util.*; | ||
import java.io.*; | ||
|
||
public class BOJ_11055_r { | ||
|
||
static int[] dp; | ||
static int[] ll; | ||
|
||
public static int DP(int n) { | ||
if(dp[n] != 0) { //안에 저장된 값이 있음 | ||
return dp[n]; | ||
} | ||
if(n == 0) { | ||
return 0; | ||
} | ||
|
||
int max = 0; | ||
for(int i = n-1;i>=0; i--) { | ||
if(ll[i] < ll[n]) { | ||
max = Math.max(DP(i), max); | ||
} | ||
} | ||
|
||
dp[n] = max + ll[n]; | ||
|
||
return 1; | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); | ||
|
||
int num = Integer.parseInt(br.readLine()); | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
dp = new int[num]; | ||
ll = new int[num]; | ||
|
||
int ans = 0; | ||
|
||
for(int i = 0; i<num; i++) { | ||
ll[i] = Integer.parseInt(st.nextToken()); | ||
} | ||
|
||
dp[0] = ll[0]; //초기화 | ||
|
||
for(int i = 1; i<num; i++) { | ||
DP(i); | ||
} | ||
|
||
for(int i = 0; i<num; i++) { | ||
ans = Math.max(ans, dp[i]); | ||
} | ||
|
||
bw.write(ans + "\n"); | ||
bw.flush(); | ||
br.close(); | ||
bw.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package BOJ.silver2; | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
|
||
public class BOJ_11722 { | ||
public static void main(String[] args) throws IOException{ | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); | ||
|
||
int num = Integer.parseInt(br.readLine()); | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
|
||
int[] ll = new int[num]; | ||
int[] dp = new int[num]; | ||
int ans = 0; | ||
|
||
//저장 | ||
for(int i = 0; i<num; i++) { | ||
ll[i] = Integer.parseInt(st.nextToken()); | ||
} | ||
|
||
dp[0] = 1; | ||
|
||
for(int i = 1; i<num; i++) { | ||
int max = 0; | ||
for(int j = i-1; j>= 0; j--) { | ||
if(ll[j] > ll[i]) { | ||
max = Math.max(max, dp[j]); | ||
} | ||
} | ||
dp[i] = max + 1; | ||
} | ||
|
||
for(int i = 0; i<num; i++) { | ||
ans = Math.max(ans, dp[i]); | ||
} | ||
bw.write(ans + "\n"); | ||
bw.flush(); | ||
bw.close(); | ||
br.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package BOJ.silver2; | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
|
||
public class BOJ_11722_r { | ||
static int[] ll; | ||
static int[] dp; | ||
|
||
public static int DP(int n) { | ||
|
||
if(dp[n] != 0) { | ||
return dp[n]; | ||
} | ||
|
||
if(n == 0) { | ||
return 0; | ||
} | ||
|
||
int max = 0; | ||
for(int i = n-1; i>=0; i--) { | ||
if(ll[n] < ll[i]) { | ||
max = Math.max(max, DP(i)); | ||
} | ||
} | ||
dp[n] = max + 1; | ||
|
||
return 1; | ||
} | ||
|
||
public static void main(String[] args) throws IOException{ | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); | ||
|
||
int num = Integer.parseInt(br.readLine()); | ||
ll = new int[num]; | ||
dp = new int[num]; | ||
int ans = 0; | ||
|
||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
for(int i = 0; i<num; i++) { | ||
ll[i] = Integer.parseInt(st.nextToken()); | ||
} | ||
|
||
dp[0] = 1; | ||
|
||
for(int i = 1; i<num; i++){ | ||
DP(i); | ||
} | ||
|
||
for(int i = 0; i<num; i++) { | ||
ans = Math.max(ans, dp[i]); | ||
} | ||
|
||
bw.write(ans + "\n"); | ||
bw.flush(); | ||
br.close(); | ||
bw.close(); | ||
} | ||
} |