http://www.usaco.org/index.php?page=viewproblem2&cpid=855
// Mixing Milk
#include <fstream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std ;
ifstream cin ("mixmilk.in") ;
ofstream cout ("mixmilk.out") ;
int main() {
int c[3], m[3] ;
for (int i=0; i<3; i++) {
cin >> c[i] ;
cin >> m[i] ;
}
for (int i=0; i<100; i++) {
if (m[i%3]+m[(i+1)%3] > c[(i+1)%3]) {
m[i%3] = m[i%3]-c[(i+1)%3] ;
m[(i+1)%3] = c[(i+1)%3] ;
}
else {
m[(i+1)%3] += m[i%3] ;
m[i%3] = 0 ;
}
}
cout << m[0] << endl << m[1] << endl << m[2] << endl ;
return 0 ;
}
Can someone help why this is only working for test cases 1 and 3?