Official
A - Kazuate Game Editorial
by
A - Kazuate Game Editorial
by
keisuke6
Editorial for printing
\(\max(A)\) が \(100\) 以下なので、それぞれの要素について条件を満たすかを愚直に \(O(N)\) で判定すれば、\(O(N \max(A))\) で解くことができます。
もしくは、配列入力の時点でそれぞれの要素がいくつあるかを数えれば、 \(O(N+ \max(A))\) で解くこともできます(以下のソースコードはここのアルゴリズムです)。 範囲外参照に注意してください。
想定解 (c++)
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int N;
cin>>N;
vector<int> C(101);
for(int i=0;i<N;i++){
int a;
cin>>a;
C[a]++;
}
bool p = true;
for(int i=1;i<=100;i++)if(C[i] && C[i] <= 10) p = false;
cout<<(p ? "No" : "Yes")<<endl;
}
posted:
last update:
