题解 | #小欧的数组修改#

小欧的数组修改

https://www.nowcoder.com/practice/9d57195bcec9415e9d12db846545ee0f

计数。

#include<bits/stdc++.h>
#define int long long
#define double long double
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef pair<int,int> PII;
const int N=3e5+10;
const int M=1e3+10;
int mod=1e9+7;
int a[N];

void solve(){
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    map<int,int>mp;
    for(int i=1;i<=n;i++) mp[a[i]]++;
    int ans=0;
    for(auto x:mp) ans=max(ans,x.y);
    if(mp.size()==1) cout<<ans<<"\n";
    else cout<<ans+1<<"\n";
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int _;
    _=1;
    //cin>>_;
    while(_--){
        solve();
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
九三阅兵看得我热泪盈眶,如果祖国需要,我随时准备入职国家电网、石油、烟草等单位,为祖国奉献一切
职场水母:好兄弟,你有偏路子记得带我一个,苟富贵,勿相忘,我也想进烟草,国家电网,石油,中央纪委,中央发改委,新华社,航天所,北京大学,清华大学,北航,北理,北郊,北邮,等等一系列单位,为国家奉献,吾辈义不容辞。
九三阅兵的激动瞬间
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务