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

#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;
}

(Visited 69 times, 1 visits today)

About the Author:

Leave A Comment