当前位置:网站首页>Acwing's 57th weekly match -- BC question is very good
Acwing's 57th weekly match -- BC question is very good
2022-06-27 05:03:00 【Wawa source】
A. Than the size — Sign in
#include<iostream>
#include<cstring>
using namespace std;
#define int long long
signed main()
{
int n;cin>>n;
int s1=0,s2=0;
for(int i=0,x;i<n;i++)cin>>x,s1+=x;
for(int i=0,x;i<n;i++)cin>>x,s2+=x;
if(s1>=s2)cout<<"Yes"<<'\n';
else cout<<"No"<<'\n';
}
B. Digital operation — Basic theorem of arithmetic
#include<iostream>
#include<cstring>
#include<set>
#include<cmath>
using namespace std;
#define int long long
set<int>S;
signed main()
{
int n;cin>>n;
if(n==1){
cout<<1<<" 0"<<'\n';return 0;}
int res=1,cnt=0;
for(int i=2;i<=n;i++)
{
int s=0;
if(n%i==0)
{
while(n%i==0)n/=i,s++;
res*=i;
S.insert(s);
}
cnt=max(s,cnt);
}
int sum=1,res2=1;
while(sum<cnt)sum*=2,res2++;
if(sum==cnt&&S.size()==1)res2--;
cout<<res<<" "<<res2<<'\n';
}
C. The longest continuous subsequence — Monotonic stack + greedy + Two points
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define int long long
const int N = 1000010;
int a[N],s[N],stk[N];
int top=0;
signed main()
{
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i],a[i]-=100;
for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
int res=0;
for(int i=1;i<=n;i++)
{
int l=0,r=top;
while(l<r)
{
int mid=l+r>>1;
if(s[i]-s[stk[mid]]>0)r=mid;
else l=mid+1;
}
if(s[i]<s[stk[top]])stk[++top]=i;
if(s[i]-s[stk[r]]>0)res=max(res,i-stk[r]);
}
cout<<res<<'\n';
}
边栏推荐
猜你喜欢

Cultural tourism light show breaks the time and space constraints and shows the charm of night tour in the scenic spot

Microservice system design -- distributed transaction service design

Redis高可用集群(哨兵、集群)

微服务系统设计——服务熔断和降级设计

golang hello 安装环境异常【已解决】
![[BJDCTF2020]The mystery of ip](/img/f8/c3a7334252724635d42c8db3d1bbb0.png)
[BJDCTF2020]The mystery of ip

Cognition - how to fill in 2022 college entrance examination volunteers

重映像(STM32)

Redis high availability cluster (sentry, cluster)

QChart笔记2: 添加鼠标悬停显示
随机推荐
ES6 0622 III
013 basics of C language: C pointer
Web3还没实现,Web5乍然惊现!
011 C language basics: C scope rules
015 basics of C language: C structure and common body
微服务系统设计——分布式定时服务设计
牛客练习赛101-C 推理小丑---位运算+思维
AD22 gerber files 点开 gerber steup 界面 有问题 官方解决方法
微服务系统设计——分布式缓存服务设计
stm32单片机引脚_如何将单片机的引脚配置为上拉输入
[station B up dr_can learning notes] Kalman filter 1
Microservice system design -- API gateway service design
014 C language foundation: C string
QChart笔记2: 添加鼠标悬停显示
007 basics of C language: C operator
Microservice system design -- microservice monitoring and system resource monitoring design
windows上安装MySQL
【B站UP DR_CAN学习笔记】Kalman滤波1
Deep dive kotlin synergy (XV): Test kotlin synergy
渗透测试-目录遍历漏洞