提交时间:2026-01-04 15:31:03
运行 ID: 80774
#include <iostream> #include <unordered_map> #include <string> using namespace std; int main() { int N; cin >> N; unordered_map<string, int> categoryCount; unordered_map<string, string> categoryMap = { {"leaves", "FOOD WASTE"}, {"watermelon peel", "FOOD WASTE"}, {"leftovers", "FOOD WASTE"}, {"paper box", "RECYCLABLE"}, {"plastic bottle", "RECYCLABLE"}, {"clothes", "RECYCLABLE"}, {"rechargeable battery", "HAZARDOUS"}, {"abandoned medicine", "HAZARDOUS"}, {"disinfectant", "HAZARDOUS"}, {"mask", "RESIDUAL WASTE"}, {"battery", "RESIDUAL WASTE"}, {"plastic bag", "RESIDUAL WASTE"} }; for (int i = 0; i < N; ++i) { string item; cin >> item; if (categoryMap.count(item)) { categoryCount[categoryMap[item]]++; } } string maxCategory; int maxCount = 0; for (const auto& pair : categoryCount) { if (pair.second > maxCount) { maxCount = pair.second; maxCategory = pair.first; } } cout << maxCategory << endl; cout << maxCount << endl; return 0; }