For referance, here is the problem - USACO
For the sample case, if I run it locally, it shows 0 10 2 (Correct output)
When ran in the usaco website, it shows
0
-1431666112
0
#include <iostream>
using namespace std;
int main()
{
int a,aMax,b,bMax,c,cMax;
cin>>aMax>>a>>bMax>>b>>cMax>>c;
for(int i=0;i<33;i++)
{
//from a to b
b+=a;
a=0;
if(b>bMax)
{
a+=b-bMax;
b=bMax;
}
//cout<<a<<" "<<b<<endl;
//from b to c
c+=b;
b=0;
if(c>cMax)
{
b+=c-cMax;
c=cMax;
}
//cout<<b<<" "<<c<<endl;
//from c to a
a+=c;
c=0;
if(a>aMax)
{
c+=a-aMax;
a=aMax;
}
//cout<<c<<" "<<a<<endl;
}
b+=a;
a=0;
if(b>bMax)
{
a+=b-bMax;
b=bMax;
}
cout<<a<<endl<<b<<endl<<c<<endl;
return 0;
}