baekjoon 20260101
This commit is contained in:
parent
fbbbaeb8e6
commit
d3c56c0194
13
code_study/Baekjoon/c/10039.c
Normal file
13
code_study/Baekjoon/c/10039.c
Normal file
@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int ans = 0;
|
||||
for(int i=0; i<5; i++) {
|
||||
int n;
|
||||
scanf("%d",&n);
|
||||
if(n < 40) n = 40;
|
||||
ans += n/5;
|
||||
}
|
||||
printf("%d\n",ans);
|
||||
return 0;
|
||||
}
|
||||
34
code_study/Baekjoon/swift/2473.swift
Normal file
34
code_study/Baekjoon/swift/2473.swift
Normal file
@ -0,0 +1,34 @@
|
||||
func solve() {
|
||||
guard let N = Int(readLine() ?? ""),
|
||||
let input = readLine()
|
||||
else { return }
|
||||
|
||||
var val: [Int] = input.split(separator: " ").compactMap{Int($0)}
|
||||
val.sort(by: <)
|
||||
var minAbs = Int.max
|
||||
var ans: [Int] = [0, 0, 0]
|
||||
|
||||
for fix in 0..<N-1 {
|
||||
var (L, R) = (fix + 1, N-1)
|
||||
|
||||
while L < R {
|
||||
let temp = val[fix] + val[L] + val[R]
|
||||
|
||||
if abs(temp) < minAbs {
|
||||
minAbs = abs(temp)
|
||||
ans = [val[fix], val[L], val[R]]
|
||||
}
|
||||
|
||||
if temp > 0 {
|
||||
R -= 1
|
||||
}
|
||||
else {
|
||||
L += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print(ans.compactMap({String($0)}).joined(separator: " "))
|
||||
}
|
||||
|
||||
solve()
|
||||
Loading…
x
Reference in New Issue
Block a user