[ # 5ํ์ฐจ ์ ๋ณด ]
- 2024๋ 7์ 28์ผ 19:00 - 22:00
- Discord ์์ ํตํ๋ก ์จ๋ผ์ธ ์คํฐ๋ ํ์ ์งํ
[ # 5ํ์ฐจ ๊ฐ์ธ ๋ชฉํ ]
Java ๋ฐฑ์ค ๋ฌธ์ ํ์ด ์งํ
- ์ค๋ฒ 4 28419๋ฒ
- ์ค๋ฒ 4 14468๋ฒ
[ # 5ํ์ฐจ ๊ฐ์ธ ํ๋ ๋ด์ฉ ]
28419๋ฒ: ๋ํ๊ธฐ
https://www.acmicpc.net/problem/28419
import java.util.*;
import java.io.*;
public class Main {
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter bw= new BufferedWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
public static void main(String[] args) throws NumberFormatException, IOException {
int N=Integer.parseInt(br.readLine());
String SSS=br.readLine();
st=new StringTokenizer(SSS);
long odd=0;
long even=0;
for(int i=0; i<N; i++) {
if(i%2==0) {
odd+=Long.parseLong(st.nextToken());
}
else {
even+=Long.parseLong(st.nextToken());
}
}
if(odd==even) {
bw.write("0");
}
else if(even<odd) {
if(N<=3) {
bw.write("-1");
}
else {
bw.write(odd-even+"");
}
}
else {
bw.write(even-odd+"");
}
bw.flush();
bw.close();
br.close();
}
}
14468๋ฒ: ์๊ฐ ๊ธธ์ ๊ฑด๋๊ฐ ์ด์ 2
https://www.acmicpc.net/problem/14468
import java.util.*;
import java.io.*;
public class Main {
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter bw= new BufferedWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
public static void main(String[] args) throws NumberFormatException, IOException {
String SSS= br.readLine();
String A[]=new String[SSS.length()];
long count=0;
Map<String,Integer> M=new HashMap<>();
for(int i=0; i<26; i++) {
M.put(""+(char)(65+i),0);
}
for(int i=0; i<SSS.length(); i++) {
A[i]=""+SSS.charAt(i);
}
for(int i=0; i<52; i++) {
M.put(A[i],M.get(A[i])+1);
if(M.get(A[i])==1) {
Map<String,Integer> mmm=new HashMap<>();
for(int a=0; a<26; a++) {
mmm.put(""+(char)(65+a),0);
}
int j=i+1;
while(true){
if(A[i].equals(A[j])) {
break;
}
else {
mmm.put(A[j],mmm.get(A[j])+1);
j+=1;
}
}
for(int q=(int)A[i].charAt(0)-65+1; q<26; q++) {
if(mmm.get(""+(char)(65+q))%2!=0) {
count+=1;
}
}
}
}
bw.write(count+"");
bw.flush();
bw.close();
br.close();
}
}
'๐ ๊ฐ์ธ ํ๋ ๋ชจ์์ง ๐ > ๐ฉ๐ปโ๐ป `24 ํ๊ณ ๋ชจ๊ฐ์ฝ ๐ฉ๐ปโ๐ป' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[`24 ํ๊ณ ๋ชจ๊ฐ์ฝ] ํ ๋ฆฌ์ปจ์ ์ฌ๊ณ 6ํ์ฐจ ๊ฐ์ธ ๋ฆฌ๋ทฐ (0) | 2024.07.30 |
---|---|
[`24 ํ๊ณ ๋ชจ๊ฐ์ฝ] ํ ๋ฆฌ์ปจ์ ์ฌ๊ณ 4ํ์ฐจ ๊ฐ์ธ ๋ฆฌ๋ทฐ (0) | 2024.07.26 |
[`24 ํ๊ณ ๋ชจ๊ฐ์ฝ] ํ ๋ฆฌ์ปจ์ ์ฌ๊ณ 3ํ์ฐจ ๊ฐ์ธ ๋ฆฌ๋ทฐ (0) | 2024.07.26 |
[`24 ํ๊ณ ๋ชจ๊ฐ์ฝ] ํ ๋ฆฌ์ปจ์ ์ฌ๊ณ 2ํ์ฐจ ๊ฐ์ธ ๋ฆฌ๋ทฐ (0) | 2024.07.14 |
[`24 ํ๊ณ ๋ชจ๊ฐ์ฝ] ํ ๋ฆฌ์ปจ์ ์ฌ๊ณ 1ํ์ฐจ ๊ฐ์ธ ๋ฆฌ๋ทฐ (0) | 2024.07.14 |