赞
踩
- // Online C++ compiler to run C++ program online
- #include<iostream>
- #include<vector>
- #include<stdlib.h>
- #include<algorithm>
- #include<string.h>
- #include<exception>
- #include<map>
- #include<cmath>
- #include<unordered_map>
- #include<set>
- #include<climits>
- #include<ctype.h>
- #include<queue>
- #include<stack>
- #include<list>
- #include<string>
-
- using namespace std;
-
- int main() {
- // 处理输入
- string inputStr;
- getline(cin, inputStr);
-
- vector<int> list;
- while (inputStr.find(",") != string::npos)
- {
- int val = inputStr.find(",");
- string str = inputStr.substr(0, val);
- list.emplace_back(atoi(str.c_str()));
- inputStr = inputStr.substr(val + 1);
- }
- list.emplace_back(atoi(inputStr.c_str()));
-
- vector<int> cars;
- int n = 0;
- for (auto& i : list)
- {
- if (i == 0)
- {
- if (0 != n) cars.push_back(n);
- n = 0;
- continue;
- }
- ++n;
- }
- if (0 != n) cars.push_back(n);
-
- int count = 0;
- for (auto val : cars) {
- //大于3的情况,最少的车,肯定尽量满足大卡车
- int m = val % 3;
- if (m != 0)
- {
- val -= m;
- ++count;
- }
- count += val / 3;
- }
-
- cout << count;
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。