UVA Solution 456 – Robotic Stacker – Solution in C,C++

UVA Onilne Judge Solution UVA-Volume 4

UVA Solution 456 – Robotic Stacker – Solution in C,C++

UVA Online Judge Solution 456 – Robotic Stacker| Volume 4
UVA Problem Link – 456 – Robotic Stacker

Problem Name: 456 – Robotic Stacker Solution
Problem Number : UVA – 456 – Robotic Stacker Solution
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 456 – Robotic Stacker Code in C/CPP:

#include <stdio.h>

int
main() {
char
s[105];
while
(gets(s)) {
int
row[6] = {};
int
i, j, k, p;
for
(i = 0; s[i]; i++) {
p = s[i]-'0';
for
(j = 0; j <= 6-p; j++) {
if
(row[j] != 20) {
for
(k = 1; k < p; k++)
if
(row[j+k] != row[j])
break
;
if
(k == p) {
for
(k = 0; k < p; k++)
row[j+k]++;
j = 10; //accept
break;
}
}
}

if
(j == 10)
continue
;
for
(j = 0; j < 6; j++) {
if
(row[j]+p <= 20) {
row[j] += p;
break
;
}
}

if
(j == 6) //not accept
break; // full
}
int
sum = 0;
for
(j = 0; j < 6; j++)
sum += row[j];
printf("%d %dn", i, 120-sum);
}

return
0;
}

Tags: UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list, UVA code in C, UVA 456 – Robotic Stacker code in C++, UVA 456 solution in C, UVA Robotic Stacker solution

Leave a Reply

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