#include <iostream>
#include <vector>
using namespace std;
int main() {
freopen("mixmilk.in", "r", stdin);
vector<int> bct_cap;
vector<int> bct_amt;
int c,a;
for(int i=0; i < 3; i++){
cin >> c >> a;
bct_cap.push_back(c);
bct_amt.push_back(a);
}
for (int i = 0; i < 100; ++i)
{
int to = (i+1) % 3;
int from = i % 3;
int pourAmt = min(bct_amt[from], bct_cap[to] - bct_amt[to]);
bct_amt[to] += pourAmt;
bct_amt[from] -= pourAmt;
}
for (int i = 0; i < bct_amt.size(); ++i)
{
cout << bct_amt[i] << "\n";
}
freopen("mixmilk.out", "w", stdout);
}
maybe that’s because of the extra end line
you should do sth like this :
for(int i = 0; i < bct_amt.size(); ++i)
{
cout << bct_amt[i];
if (i < bct_amt.size()-1) cout << "\n";
}
It’s because it is asking you to write your output to the file “mixmilk.out”, not standard.
Your freopen
is at the end, rather than at the beginning.
1 Like