baekjoon 20260103
This commit is contained in:
parent
686fb84ef8
commit
b6564903d1
31
code_study/Baekjoon/c/1106.c
Normal file
31
code_study/Baekjoon/c/1106.c
Normal file
@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_COST 100000
|
||||
|
||||
int min(int a, int b) {
|
||||
return a > b ? b : a;
|
||||
}
|
||||
|
||||
int dp[1101];
|
||||
|
||||
int main() {
|
||||
int C, N;
|
||||
scanf("%d %d",&C, &N);
|
||||
|
||||
dp[0] = 0;
|
||||
for(int i=1; i<=C+100; i++) dp[i] = MAX_COST;
|
||||
|
||||
while(N--) {
|
||||
int cost, man;
|
||||
scanf("%d %d",&cost, &man);
|
||||
|
||||
for(int c=man; c<C+101; c++) dp[c] = min(dp[c], dp[c-man] + cost);
|
||||
}
|
||||
|
||||
int ans = MAX_COST;
|
||||
for(int i=C; i<C+101; i++) ans = min(ans, dp[i]);
|
||||
|
||||
printf("%d\n",ans);
|
||||
|
||||
return 0;
|
||||
}
|
||||
8
code_study/Baekjoon/swift/10817.swift
Normal file
8
code_study/Baekjoon/swift/10817.swift
Normal file
@ -0,0 +1,8 @@
|
||||
func solve() {
|
||||
guard let input = readLine() else { return }
|
||||
var nums = input.split(separator: " ").compactMap{Int($0)}
|
||||
nums.sort()
|
||||
print(nums[1])
|
||||
}
|
||||
|
||||
solve()
|
||||
Loading…
x
Reference in New Issue
Block a user