--- title: "最大数量" created: 2025-11-28 tags: - 算法 --- # 最大数量 ## 题目 [最大数量](https://www.acwing.com/problem/content/description/4791/) ![[image-6fb76373.png]] ## 思路分析 可以把时间当字符串存 也可以换算成分钟存 当字符串的话 就是借鉴第一题 中间加个空格 然后又要计数 借鉴第二题 把string当键 int当值记录每个出现的次数 转换成分的话 直接值做下标计数即可(桶排序) ## 代码实现 ```cpp #include using namespace std; unordered_map h; int n; int main() { cin>>n; int res=0; while(n--) { string hh,mm; cin>>hh>>mm; string key=hh+' '+mm; h[key]++; res=max(res,h[key]); } cout< using namespace std; const int N=1500; int n; int cnt[N]; int main() { cin>>n; int res=0; while(n--) { int hh,mm; cin>>hh>>mm; int time=hh*60+mm; cnt[time]++; res=max(res,cnt[time]); } cout<