You are viewing a single comment's thread. Return to all comments →
using namespace std;
string fairRations(vector B) { int loaves = 0; int n = B.size();
for (int i = 0; i < n - 1; ++i) { if (B[i] % 2 != 0) { B[i]++; B[i + 1]++; loaves += 2; } } if (B[n - 1] % 2 != 0) { return "NO"; } else { return to_string(loaves); }
}
int main() { ios::sync_with_stdio(false); cin.tie(NULL);
int n; cin >> n; vector<int> B(n); for (int i = 0; i < n; ++i) cin >> B[i]; cout << fairRations(B) << "\n"; return 0;
Seems like cookies are disabled on this browser, please enable them to open this website
Fair Rations
You are viewing a single comment's thread. Return to all comments →
include
include
include
using namespace std;
string fairRations(vector B) { int loaves = 0; int n = B.size();
}
int main() { ios::sync_with_stdio(false); cin.tie(NULL);
}