热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_56645631
苏哈哈462
5 年前
trueweixin_56645631

#707 A
思路:模拟;
#include<stdio.h>
#include<string.h>
int ai[100010];
int bi[100010];
int ci[100010];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&ai[i],&bi[i]);
}
for(int i=1;i<=n;i++)
{
scanf("%d",&ci[i]);
}
long long res=0;
for(int i=1;i<=n;i++)
{
res+=ai[i]-bi[i-1]+ci[i];
if(i==n)break;
res+=(bi[i]-ai[i]+1)/2;
if(res>=bi[i]);
else res=bi[i];
}
printf("%lld\n",res);
}
return 0;
}

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
博主简介:https://cplusplus.blog.csdn.net/article/details/115873169
立即登录