Skip to content

Added Problem 158 B #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions codeforces/taxi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CXX := g++
CXXFLAGS := -std=c++14 -Wall -o out

default: out run

out: main.cpp
$(CXX) $(CXXFLAGS) main.cpp

clean:
$(RM) out

run:
./out
3 changes: 3 additions & 0 deletions codeforces/taxi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# README

[http://codeforces.com/problemset/problem/158/B](http://codeforces.com/problemset/problem/158/B)
44 changes: 44 additions & 0 deletions codeforces/taxi/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

#include<bits/stdc++.h>
using namespace std;
typedef long long int INT;

int main()
{
int n;
cin>>n;
int a[4]={0};
int x;
for(int i=0;i<n;i++)
{
cin>>x;
a[x-1]++;
/*
Maps number of groups of 1 -> a[0]
number of groups of 2 -> a[1]
number of groups of 3 -> a[2]
number of groups of 4 -> a[3]
*/
}
int group4=a[3];
int group3_1=min(a[2],a[0]);
int left_3=a[2]-group3_1;
int left_1=a[0]-group3_1;
int group2_2=a[1]/2;
int left_2=a[1]%2;
int group2_1_1=left_2;
if(group2_1_1 && left_2)
{
if(left_1>=2)
{
left_1-=2;
}
else if(left_1>=1)
{
left_1-=1;
}
}
int group1=ceil(left_1/4.0);
int ans=group4 + group3_1 + group2_2 + left_3 + group2_1_1 + group1;
cout<<ans;
}