题目链接
A Generous Kefa
找字母出现的最大次数
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<iomanip>
//#define mem(dp,a) memset(dp,a,sizeof(dp))
//#define fo(i,n) for(int i=0;i<(n);i++)
//#define INF 0x3f3f3f3f
#define fread() freopen("data.txt","r",stdin)
#define fwrite() freopen("out.out","w",stdout)
using namespace std;
typedef long long ll;
const ll N = 10005;
const ll MOD = 1000000007;
string s;
int a[28];
int b[1000];
int n,k;
int main()
{
ios_base::sync_with_stdio(false);
// fread();
cin >> n >> k;
cin >> s;
for(int i=0;i<s.size();i++)
{
a[s[i] - 'a'] ++;
}
int len = *max_element(a,a+26);
if(k<len)
{
cout <<"NO"<<endl;
}
else
{
cout <<"YES"<<endl;
}
return 0;
}
B - Godsend
出现奇数先手必赢
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<iomanip>
//#define mem(dp,a) memset(dp,a,sizeof(dp))
//#define fo(i,n) for(int i=0;i<(n);i++)
//#define INF 0x3f3f3f3f
#define fread() freopen("data.txt","r",stdin)
#define fwrite() freopen("out.out","w",stdout)
using namespace std;
typedef long long ll;
const ll N = 10005;
const ll MOD = 1000000007;
int n;
ll a[1000005];
int main()
{
ios_base::sync_with_stdio(false);
// fread();
cin >>n;
ll sum = 0;
int cto =0 ;
for(int i=0;i<n;i++)
{
cin >> a[i];
if(a[i]%2)
{
cto++;
}
sum += a[i];
}
if(sum%2)
{
cout<<"First"<<endl;
}
else
{
if(cto==0)
{
cout<<"Second"<<endl;
}
else
{
cout<<"First"<<endl;
}
}
return 0;
}
C - Leha and Function
分析F函数,分别对a、b排序,逆序对应就好
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<iomanip>
//#define mem(dp,a) memset(dp,a,sizeof(dp))
//#define fo(i,n) for(int i=0;i<(n);i++)
//#define INF 0x3f3f3f3f
#define fread() freopen("data.txt","r",stdin)
#define fwrite() freopen("out.out","w",stdout)
using namespace std;
typedef long long ll;
const ll N = 200005;
const ll MOD = 1000000007;
struct node{
int x;
int ind;
bool operator<(node y) const
{
return x<y.x;
}
};
int n;
int a[N];
int ans[N];
vector<node> b;
node nt;
int main()
{
ios_base::sync_with_stdio(false);
// fread();
cin >>n;
for(int i=0;i<n;i++)
{
cin >>a[i];
}
for(int i=0;i<n;i++)
{
cin >> nt.x;
nt.ind = i;
b.push_back(nt);
}
sort(a,a+n);
sort(b.begin(),b.end());
for(int i=0;i<n;i++)
{
// cout <<b[i].ind <<endl;
ans[ b[i].ind ] = a[n-1-i];
}
for(int i=0;i<n;i++)
{
cout <<ans[i]<<" ";
}
return 0;
}