baekjoon 20260213
This commit is contained in:
parent
50c68e096f
commit
1dd473dccc
61
code_study/Baekjoon/c/1516.c
Normal file
61
code_study/Baekjoon/c/1516.c
Normal file
@ -0,0 +1,61 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int N;
|
||||
|
||||
int build_graph[501][501];
|
||||
int build_time[501];
|
||||
|
||||
int indegree[501];
|
||||
int qu[501];
|
||||
int front = -1, rear = 0;
|
||||
|
||||
int res[501];
|
||||
|
||||
int max(int a, int b) {
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
int main() {
|
||||
scanf("%d",&N);
|
||||
|
||||
for(int i=1; i<=N; i++) {
|
||||
scanf("%d", &build_time[i]);
|
||||
|
||||
while(1) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
if(n == -1) break;
|
||||
|
||||
build_graph[n][++build_graph[n][0]] = i;
|
||||
indegree[i]++;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=1; i<=N; i++) {
|
||||
if(indegree[i] == 0) {
|
||||
qu[rear++] = i;
|
||||
res[i] = build_time[i];
|
||||
}
|
||||
}
|
||||
|
||||
while(front < rear) {
|
||||
int now = qu[++front];
|
||||
|
||||
for(int i=1; i<=build_graph[now][0]; i++) {
|
||||
int next = build_graph[now][i];
|
||||
indegree[next]--;
|
||||
|
||||
res[next] = max(res[next], res[now] + build_time[next]);
|
||||
|
||||
if(indegree[next] == 0) {
|
||||
qu[rear++] = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=1; i<=N; i++) {
|
||||
printf("%d\n", res[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
23
code_study/Baekjoon/python/2476.py
Normal file
23
code_study/Baekjoon/python/2476.py
Normal file
@ -0,0 +1,23 @@
|
||||
import sys
|
||||
input = sys.stdin.readline
|
||||
|
||||
N = int(input())
|
||||
maxPrice = 0
|
||||
|
||||
for _ in range(N) :
|
||||
a, b, c = map(int, input().split())
|
||||
temp = 0
|
||||
|
||||
if a == b == c :
|
||||
temp = 10000 + a*1000
|
||||
elif a == b or b == c :
|
||||
temp = 1000 + b*100
|
||||
elif a == c :
|
||||
temp = 1000 + a*100
|
||||
else :
|
||||
temp = max([a,b,c])*100
|
||||
|
||||
if maxPrice < temp :
|
||||
maxPrice = temp
|
||||
|
||||
print(maxPrice)
|
||||
Loading…
x
Reference in New Issue
Block a user