Changed the folder structure of codeforces problemsets
This commit is contained in:
47
codeforces/problemsets/taxi/a.cpp
Normal file
47
codeforces/problemsets/taxi/a.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int n, a, result = 0, ones = 0, twos = 0, threes = 0;
|
||||
cin >> n;
|
||||
|
||||
for(int i = 0; i < n; i++){
|
||||
cin >> a;
|
||||
if(a != 4){
|
||||
if(a == 1){
|
||||
ones++;
|
||||
} else if(a == 2){
|
||||
twos++;
|
||||
} else{
|
||||
threes++;
|
||||
}
|
||||
} else{
|
||||
result++;
|
||||
}
|
||||
}
|
||||
|
||||
int onethreegroups = min(ones, threes);
|
||||
result += threes;
|
||||
ones -= onethreegroups;
|
||||
|
||||
int doubletwos = twos / 2;
|
||||
result += doubletwos;
|
||||
twos -= doubletwos * 2;
|
||||
|
||||
if(twos == 1){
|
||||
result++;
|
||||
ones -= min(2, ones);
|
||||
}
|
||||
|
||||
result += ceil((float)ones / 4);
|
||||
|
||||
cout << result;
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user