C++ 郊游拼车问题 - 最少出租车数量计算
#include
int main() {
int n;
cin >> n;
vector
vector<int> count(4, 0);
for (int i = 0; i < n; i++) {
count[s[i]-1]++;
}
int taxiCount = count[3];
taxiCount += count[2];
count[0] = max(0, count[0] - count[2]);
taxiCount += (count[1] + 2 * count[0] + 3) / 4;
cout << taxiCount << endl;
return 0;
}
AI 优化版
原文地址:https://www.cveoy.top/t/topic/quhG 著作权归作者所有。请勿转载和采集!