1. 程式人生 > >903C. Boxes Packing#俄羅斯套娃問題(map使用)

903C. Boxes Packing#俄羅斯套娃問題(map使用)

com sin ace 測試數據 style esp ems 普通 post

題目出處:http://codeforces.com/problemset/problem/903/C

題目大意:求這組數據中數據出現的最大重復次數

#include<iostream>
#include<map>
using namespace std;
int main(){
    int n;    cin>>n;
    int x,ans=0;
    map<int,int> t;
    for(int i=0;i<n;i++){
        cin>>x;    t[x]++;
        ans = ans>t[x]?ans:t[x];
    }
    cout
<<ans; return 0; }

解題思路也是簡單,但是測試數據過大情況下,普通方式無法解決,這裏應用了map

詳細對於#include<map>的了解百度都有

903C. Boxes Packing#俄羅斯套娃問題(map使用)