请大家帮我想一下,我那5个测试点WA了,谢谢

学术版

50分代码
by wape520 @ 2020-08-06 13:17:26


```#include<iostream> using namespace std; int a[110],cnt; int main(){ int n,t,k; cin>>n>>k; for(int i=1;i<=n;i++){ cin>>t; a[t]++; if(a[t]==1) cnt++; } if(cnt==k) { cout<<"YES"; } else if(cnt!=k) { cout<<"NO"; } return 0; }
by wape520 @ 2020-08-06 13:17:36


cnt>=k的时候输出YES
by w23c3c3 @ 2020-08-06 13:23:17


@[w23c3c3](/user/109942) 谢谢100分了
by wape520 @ 2020-08-06 13:25:08


@[wape520](/user/345952) ``` #include<bits/stdc++.h> using namespace std; int a[110],cnt; int main(){ int n,t,k; cin>>n>>k; for(int i=1;i<=n;i++){ cin>>t; a[t]++; if(a[t]==1) cnt++; } if(cnt>=k) { cout<<"YES"; } else{ cout<<"NO"; } return 0; } ```
by 仗剑_天涯 @ 2020-08-06 13:25:12


```#include<bits/stdc++.h> using namespace std; int a[110],cnt; int main(){ int n,t,k; cin>>n>>k; for(int i=1;i<=n;i++){ cin>>t; a[t]++; if(a[t]==1) cnt++; } if(cnt>=k) { cout<<"YES"; } else{ cout<<"NO"; } return 0; }```cpp
by zyf2009 @ 2020-08-06 14:27:43


|