https://i1.wp.com/eblogarithm.com/wp-content/uploads/2017/07/Codeforces-Round-423-Div-2-rated-based-on-VK-Cup-Finals-problem-A-Restaurant-Tables-Solution-in-CC1.png?fit=640%2C360

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 33 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: