baekjoon 20260101

This commit is contained in:
songyc macbook 2026-01-01 21:35:43 +09:00
parent fbbbaeb8e6
commit d3c56c0194
2 changed files with 47 additions and 0 deletions

View 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;
}

View 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()