int main()
{
unsigned long int b[3][3],min,j;
int no ;
while(scanf("%ld %ld %ld %ld %ld %ld %ld %ld %ld",&b[0][0],&b[0][1],&b[0][2],&b[1][0],&b[1][1],&b[1][2],&b[2][0],&b[2][1],&b[2][2]) == 9)
{
j = min = no = 0;
//for bcg
j = b[1][0]+b[2][0] + b[0][2]+b[2][2] + b[0][1]+b[1][1];
min = j;
no = 1;
// for bgc
j = b[1][0]+b[2][0] + b[0][1]+b[2][1] + b[0][2]+b[1][2];
if (j<min)
{
min = j;
no = 2;
}
// for cbg
j = b[1][2]+b[2][2] + b[0][0]+b[2][0] + b[0][1]+b[1][1];
if (j < min )
{
min = j;
no = 3;
}
//for cgb
j = b[1][2]+b[2][2] + b[0][1]+b[2][1] + b[0][0]+b[1][0];
if (j < min )
{
min = j;
no = 4;
}
//for gbc
j = b[1][1]+b[2][1] + b[0][0]+b[2][0] + b[0][2]+b[1][2];
if (j < min )
{
min = j;
no = 5;
}
// for gcb
j = b[1][1]+b[2][1] + b[0][2]+b[2][2] + b[0][0]+b[1][0];
if (j < min )
{
min = j;
no = 6;
}
switch(no)
{
case 1:
printf("BCG %ld",min);
break;
case 2:
printf("BGC %ld",min);
break;
I cannot see it on the board, but I suppose you put '\n' in your printfs. Your code seems ok, but for display or scan an unsigned long, you should use "%lu".
[pascal]Const
l: array [0..2] of char = ('C','B','G');
Var
i,s,tot: Longint;
r: string[3];
n: array [1..9] of longint;
Procedure intenta (a,b,c: longint);
begin
if (n[a]+n+n[c]) > s then
begin
s:= n[a]+n+n[c];
r:= l[a mod 3] + l + l[c mod 3];
end;
end;
Begin
While (not eof(input)) do
begin
tot:= 0; s:= 0;
for i:= 1 to 9 do
begin
read(input,n);
Inc(tot, n);
end;
intenta(1,6,8 ); intenta(1,5,9); intenta(3,4,8 );
intenta(3,5,7); intenta(2,4,9); intenta(2,6,7);
writeln(output,r,' ',tot -s);
end;
End.[/pascal]
There are 10 kind of people on this world: those who understand binary and those who don't!
You are accumulating larger values of s in intenta as you try out
the different possibilities. I think your mistake is in assuming that
the smallest value for bottle movements is total - the largest value.
Just accumulate on the smallest value instead and forget the
subtraction from total idea.
****************************************
Your program has died with signal 25 (SIGXFSZ). Meaning:
File size limit exceeded
****************************************
I got above error when I sent problem 102.
I do not know how to ranslate the judge's response
Can some body PLZ help me?
Thanx very much
maybe you try to send file with your program, which exceeds limit ?
(40 kB If I remember ...)
I don't know, which other posibilities could be ...
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Because of your mail server system's operations, your mail could be attach dummy code.... I experienced similar case last year.
If your source code seems no problems, then trying online submit or
sending by other mail server.
Oh, I can hardly understand your code.
First, why you output something like 'IVM' other than that given in the question 'BCG'.
Second, how come you compare teo integers?
if b[4]=b[5] or b[6] then
for example, b[5]=30 and b[6]=50
then your code is doing :
I have got AC.
This is a very easy problem.
Just check all variations of BCG in a cycle to get the maximum sum of the glasses in bins. And don't forget to choose first in alphabetical order.
Good luck. I hope that it can help you.
[quote]Somebody, please take a look at my code and try give some idea about how to fix it. The trouble is, for example, inputs like 7 8 24 28 42 0 50 19 36 work very well, but some like 50 10 5 20 10 5 10 20 10 don
if b[1]<b[2] and b[3] and b[4] and b[5] and b[6] then
I think what you want to write should be
[pascal]if (b[1]<b[2]) and (b[1]<b[3]) and (b[1]<b[4]) and
(b[1]<b[5]) and (b[1]<b[6]) then[/pascal]
And you need not to have nested if, simply six if statements are enough.
You just need to find the strictly smallest one. Do you see it?