Last active
July 24, 2017 21:43
-
-
Save MohamedTaha98/b15198cf98f95d7e95fa5c595719f5e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
long n, a, b, c = 0, unserved = 0; | |
cin >> n >> a >> b; | |
long group[n]; | |
for (int i = 0; i < n; i++) { | |
cin >> group[i]; | |
if (group[i] == 1) { | |
if (a > 0) | |
a--; | |
else if (b > 0 && c == 0) { | |
c++; | |
b--; | |
} | |
else if (c > 0) | |
c--; | |
else | |
unserved += 1; | |
} | |
else if (group[i] == 2) { | |
if (b == 0) | |
unserved += 2; | |
else | |
b--; | |
} | |
} | |
cout << unserved; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment