baekjoon 20260213

This commit is contained in:
songyc macbook 2026-02-14 00:15:42 +09:00
parent 50c68e096f
commit 1dd473dccc
2 changed files with 84 additions and 0 deletions

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

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