Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[박희경] 16주차 과제제출 #113

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions week16/BOJ_1_20115/박희경_20115.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package BOJ_1_20115;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class 박희경_20115 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;

int N = Integer.parseInt(br.readLine());
int[] arr = new int[N];

int max = 0;
st = new StringTokenizer(br.readLine());
for(int i = 0; i < N; i++) {
arr[i] = Integer.parseInt(st.nextToken());
max = Math.max(arr[i], max);
}
double res = max;
for(int i = 0; i < N; i++) {
if(arr[i] == max)
continue;
res += arr[i]/2.0;
}
System.out.println(res);
}
}
39 changes: 39 additions & 0 deletions week16/BOJ_2_12933/박희경_12933.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package BOJ_2_12933;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class 박희경_12933 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();

int[] arr = new int[6];
int size = str.length();
int max = 0;
arr[0] = size;

for(int i = 0; i < size; i++) {
int n = 0;
if(str.charAt(i) == 'q') n = 1;
if(str.charAt(i) == 'u') n = 2;
if(str.charAt(i) == 'a') n = 3;
if(str.charAt(i) == 'c') n = 4;
if(str.charAt(i) == 'k') n = 5;
if(arr[n - 1] == 0) {
System.out.println("-1");
return;
}
arr[n]++;
arr[n - 1]--;
max = Math.max(max, arr[1] + arr[2] + arr[3] + arr[4]);
}

if(arr[5] * 5 != size) {
System.out.println("-1");
return;
}
System.out.println(max);
}
}
53 changes: 53 additions & 0 deletions week16/BOJ_5_21921/박희경_21921.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package BOJ_5_21921;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class 박희경_21921 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());

int N = Integer.parseInt(st.nextToken());
int X = Integer.parseInt(st.nextToken());

int[] arr = new int[N];

st = new StringTokenizer(br.readLine());
for(int i = 0; i < N; i++){
arr[i] = Integer.parseInt(st.nextToken());
}

int end = 0;
int sum = 0;
int max = 0;
int count = 1;

for(int i=0; i < N; i++){
while((end - i < X) && end < N){
sum += arr[end];
end++;
}

if(max == sum){
count++;
}
else if(max < sum){
max = sum;
count = 1;
}

sum -= arr[i];
}

if(max == 0){
System.out.println("SAD");
return;
}

System.out.println(max);
System.out.println(count);
}
}