UVA Solution 452 – Project Scheduling – Solution in C, C++

UVA Onilne Judge Solution UVA-Volume 4

UVA Solution 452 – Project Scheduling – Solution in C, C++

UVA Online Judge Solution 452 – Project Scheduling | Volume 4
UVA Problem Link – 452 – Project Scheduling https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=393

Problem Name: 452 – Project Scheduling
Problem Number : UVA – 452 – Project Scheduling
Online Judge : UVA Online Judge Solution
Volume: 4
Solution Language : C, C plus plus

UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list

UVA Solution 452 – Project Scheduling Code in C,CPP:

#include <stdio.h>
#include <string.h>

int
main() {
int
t, v;
char
line[100], h[2];
scanf("%d ", &t);
while
(t--) {
int
map[26][26] = {}, day[26] = {}, mt[26] = {};
int
i, j, done[26] = {};
while
(gets(line)) {
if
(line[0] == '')
break
;
sscanf(line, "%s %d", h, &v);
j = h[0]-'A', done[j] = 1;
day[j] = v;
for
(i = strlen(line)-1; i >= 0; i--) {
if
(line[i] < 'A' || line[i] > 'Z')
break
;
map[j][mt[j]++] = line[i]-'A';
}
}

int
fin[26] = {}, used[26] = {};
int
max, ans = 0;
while
(1) {
int
flag = 0;
for
(i = 0; i < 26; i++) {
if
(used[i] == 0 && done[i] == 1) {
max = 0;
for
(j = 0; j < mt[i]; j++) {
if
(used[map[i][j]] == 0)
break
;
if
(fin[map[i][j]] > max)
max = fin[map[i][j]];
}

if
(j == mt[i]) {
fin[i] = max+day[i];
if
(fin[i] > ans)
ans = fin[i];
used[i] = 1;
flag = 1;
}
}
}

if
(flag == 0)
break
;
}

printf("%dn", ans);
if
(t)
puts("");
}

return
0;
}

Tags: UVA Online Judge Solution, UVA OJ Solution list, UVA 452 – Project Scheduling Problems Solution, UVA solver, UVA all problem solution list, UVA 452 code in C, UVA Project Scheduling  code in C++, UVA Project Scheduling  solution in C, UVA 452 solution

Leave a Reply

Your email address will not be published. Required fields are marked *