继续Brush,brush,brush.
友情提醒:
找到CodeForces最近的5场比赛:
比赛名称:Codeforces Round #792 (Div. 1 + Div. 2)
比赛时间:2022-05-19 22:35:00
比赛链接:https://codeforces.com/contest/1684
比赛名称:Codeforces Round #793 (Div. 2)
比赛时间:2022-05-22 22:35:00
比赛链接:https://codeforces.com/contest/1682
比赛名称:Educational Codeforces Round 129 (Rated for Div. 2)
比赛时间:2022-05-23 22:35:00
比赛链接:https://codeforces.com/contest/1681
比赛名称:Codeforces Round #794 (Div. 2)
比赛时间:2022-05-26 01:35:00
比赛链接:https://codeforces.com/contest/1686
比赛名称:Codeforces Round #794 (Div. 1)
比赛时间:2022-05-26 01:35:00
比赛链接:https://codeforces.com/contest/1685
目录
A - Tokitsukaze and All Zero Sequence
A - Tokitsukaze and All Zero Sequence
题目大意:
Tokitsukaze有一个长度为n的序列a。对于每个操作,她选择两个数字ai和aj(i≠j; 1≤i,j≤n) 。如果ai=aj,将其中一个更改为0。否则,将两者都更改为min(ai,aj)。Tokitsukaze想知道将序列中的所有数字更改为0的最小操作数。可以证明,答案总是存在的。
题目思路:不硬做,思维题。
AC代码:
#include<bits/stdc++.h>
using namespace std;
#define AC return 0;
#define geta(n,m); for(int i=n;i<m;i++){cin>>a[i];}
void solve(){
int n; cin>>n;
vector<int>a(n+2);
vector<int>b(112);
geta(0,n);
for(int i=0;i<110;i++) b[i]=0;
for(int i=0;i<n;i++) b[a[i]]++;
if(b[0]){
cout<<n-b[0]<<endl;
return;
}
for(int i=0;i<110;i++){
if(b[i]>=2){
cout<<n<<endl;
return;
}
}
cout<<n+1<<endl;
return;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int tc; cin>>tc;
while(tc--) solve();
AC
}
//ACplease!!!
/* printf(" \n");
printf(" \n");
printf(" * * * * * * * * * * * * \n");
printf(" * * * * * * * * \n");
printf(" * * * * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * \n");
*/