4603. 最大价值
int n;
const int N=110;
int s[N];
void solve()
{
cin>>n;
string s;
cin>>s;
int ans=0;
for(int i=0;i<n;i++)
{
if(s[i]=='A')
{
int res=0;
for(int j=i+1;j<n;j++)
{
if(s[j]=='P')res++;
else break;
}
ans=max(ans,res);
}
}
cout<<ans<<endl;
}
4604. 集合询问
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps=1e-7;
const int base=131;
#define x first
#define y second
#define int long long
#define lb long double
#define ull unsigned long long
#define pb push_back
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define dwn(i,n,x) for(int i=n;i>=x;i--)
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
int Mod(int a,int mod){return (a%mod+mod)%mod;}
int lowbit(int x){return x&-x;}
int qmi(int a, int k, int p){int res = 1 % p;while (k){if (k & 1) res = Mod(res * a , p);a = Mod(a * a , p);k >>= 1;}return res;}
int inv(int a,int mod){return qmi(a,mod-2,mod);}
int n,m;
map<int,int>mp;
int get(int x)
{
int res=0,idx=0;
while(x)
{
res+=(x&1)<<idx++;
x/=10;
}
return res;
}
void solve()
{
string op;
int x;
cin>>op>>x;
if(op=="+")mp[get(x)]++;
else if(op=="-")mp[get(x)]--;
else cout<<mp[get(x)]<<endl;
}
signed main()
{
io;
int _;_=1;
cin>>_;
while(_--)solve();
return 0;
}
4605. 最大周长
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps=1e-7;
const int base=131;
#define x first
#define y second
#define int long long
#define lb long double
#define ull unsigned long long
#define pb push_back
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define dwn(i,n,x) for(int i=n;i>=x;i--)
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
int Mod(int a,int mod){return (a%mod+mod)%mod;}
int lowbit(int x){return x&-x;}
int qmi(int a, int k, int p){int res = 1 % p;while (k){if (k & 1) res = Mod(res * a , p);a = Mod(a * a , p);k >>= 1;}return res;}
int inv(int a,int mod){return qmi(a,mod-2,mod);}
int n;
const int N=300010;
int x[N],y[N];
void solve()
{
cin>>n;
int u=-ll_INF,d=ll_INF,l=ll_INF,r=-ll_INF;
rep(i,1,n)
{
cin>>x[i]>>y[i];
u=max(u,y[i]),d=min(d,y[i]);
l=min(l,x[i]),r=max(r,x[i]);
}
int res=0;
rep(i,1,n)
res=max(res,max(u-y[i],y[i]-d)+max(r-x[i],x[i]-l));
cout<<res*2<<' ';
rep(i,4,n)
cout<<2*(u-d+r-l)<<' ';
}
signed main()
{
io;
int _;_=1;
while(_--)solve();
return 0;
}