PS:这一场真的是上分场,只要手速快就行。然而在自己做的时候不用翻译软件,看题非常吃力非常慢,还有给队友讲D题如何判断的时候又犯了一个毛病,一定要心平气和,比赛也要保证,不要用翻译软件做题;

Codeforces732A

水题;

#include<cstdio>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL mod=1e9+7; int main()
{
int n,m;
scanf("%d%d",&n,&m);
int tmp;
for(int i=0;;i++)
{
tmp=i*10;
if(tmp%n==0&&tmp)
{
printf("%d\n",tmp/n);
return 0;
}
tmp+=m;
if(tmp%n==0)
{
printf("%d\n",tmp/n);
return 0;
}
}
}

Codeforces 732B.
Cormen — The Best Friend Of a Man

求一个最少数量,使得连续两个是>=k

保证b[i]>=a[i];

我肯定是加中间的,加中间的话两边都能利用,而且一定要加;

#include<cstdio>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL mod=1e9+7;
const int N=5e2+10;
int a[N];
int b[N]; int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
int tmp,flag=0,ans=0;
b[1]=a[1];
for(int i=2;i<=n;i++)
{
tmp=b[i-1]+a[i];
if(tmp>=m)
b[i]=a[i];
else
{
b[i]=m-b[i-1];
ans+=b[i]-a[i];
}
}
printf("%d\n",ans);
for(int i=1;i<=n;i++)
{
if(i!=1) printf(" ");
printf("%d",b[i]);
}
return 0;
}

Codeforces 732C
- Sanatorium

最大和最小的数量<=1就一定能全部进行结束,所以求一个最大,保证和最大的差值<=1就好了;

#include<cstdio>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef __int64 LL;
const int INF=0x3f3f3f3f;
const LL mod=1e9+7;
LL a[4];
int main()
{
LL mx;
scanf("%I64d",&a[1]);
mx=a[1];
for(int i=2;i<=3;i++)
{
scanf("%I64d",&a[i]);
mx=max(a[i],mx);
}
LL ans=0;
for(int i=1;i<=3;i++)
{
if(a[i]+1>=mx)
continue;
ans+=mx-1-a[i];
}
printf("%I64d\n",ans);
return 0;
}

Codeforces 732D

只要二分一个答案,然后判断满不满足就行了,判断的时候倒着判断,开了两个值代表需要准备的天数,已经准备的天数维护一下就好了;

#include<cstdio>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std; const int N=1e5+10;
int a[N],w[N];
bool vis[N];
int m; bool Judge(int n)
{
int sum,x,y,num;
memset(vis,false,sizeof(vis));
x=y=num=0;
for(int i=n;i>=1;i--)
{
if(!a[i])
{
if(x>y)
y++;
}
else
{
if(vis[a[i]])
{
if(x>y)
y++;
}
else
{
num++;
x+=w[a[i]];
vis[a[i]]=true;
}
}
if(x==y&&num==m)
return true;
}
return false;
} int solve(int n)
{
int left=1,right=n;
while(left<right)
{
int mid=left+(right-left)/2;
if(Judge(mid))
right=mid;
else
left=mid+1;
}
return left;
} int main()
{
int n;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=m;i++)
scanf("%d",&w[i]);
if(!Judge(n))
{
puts("-1");
return 0;
}
int ans;
ans=solve(n);
printf("%d\n",ans);
return 0;
}

最新文章

  1. sonarqube插件开发(一) 环境搭建
  2. BLE资料应用笔记 -- 持续更新
  3. u3d_Shader_effects笔记3 half diffuse 和 ramp texture
  4. C++_Eigen函数库用法笔记——The Array class and Coefficient-wise operations
  5. 【二叉树、堆】15轻院校赛-J-堆
  6. 【HeadFirst设计模式】11.代理模式
  7. url编码解码-js编码、C#编码
  8. avalon
  9. T-SQL语句——UNION, EXCEPT, INTERSECT
  10. Linux下搭建Hadoop具体步骤
  11. HDU2844_Coins【多重背包】【二进制优化】
  12. Webdriver API之元素定位
  13. POJ1850-Code 递推数学
  14. Java字符编码浅析
  15. IE bug:ajax请求返回304解决方案
  16. Jeff Atwood:Google的头号UI问题
  17. Java 中 Equals和==的区别(转)
  18. (转)Db2 数据库常见堵塞问题分析和处理
  19. Windows Server 2016-Win Ser 2016新增功能
  20. WPF Path总结(一)

热门文章

  1. STL_算法_查找算法(find、find_if)
  2. c# vs2010 连接access数据库
  3. Linux环境下安装ActiveMq
  4. UIVisualEffectView
  5. Protocol_OSPF
  6. Python升级已经安装的第三方库
  7. android SDK中添加自定义api【转】
  8. Gradients渐变属性
  9. php-get和post请求
  10. Android Studio 使用Gradle多渠道打包