Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals), problem: (A) Restaurant Tables Solution in C/C++

By |2017-07-24T18:00:07+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include <iostream> using namespace std; int main() { int n,a,b,bg=0,d=0,x; cin>>n>>a>>b; while(n--){ cin>>x; if(x==1) {if(a)a--; else if(b)b--,bg++; else if(bg)bg--; else d++; } else {if(b)b--;else d+=2; } } cout<<d; }