题目链接

感谢 http://blog.csdn.net/txgang/article/details/77568491

以下供参考

getchar读入法  2683MS

FastIO法  MX=1e2  561MS

      MX=1e3  436MS

      MX=1e4  499MS

      MX=1e5  452MS

      MX=1e6  483MS

      MX=1e7  499MS

#include<bits/stdc++.h>
using namespace std;
typedef long long LL; namespace FastIO
{ //使用时直接调用 read(x)即可,
const static int MX=1e6;
bool IOerror=;
char nc()
{
static char buf[MX],*p1=buf+MX,*pend=buf+MX;
if(p1==pend)
{
p1=buf;
pend=buf+fread(buf,,MX,stdin);
if(pend==p1)
{
IOerror=;
return -;
}
}
return *p1++;
}
inline bool blank(char ch)
{
return ch==' '||ch=='\n'||ch =='\r'||ch =='\t';
}
inline int read(int& x)
{
char ch;
int sign=;
while(blank(ch=nc()));
if(IOerror) return ;
if(ch=='-') sign=-,ch=nc();
for(x=ch-''; (ch=nc())>=''&&ch<=''; x=x*+ch-'');
x*=sign;
return ;
}
inline int read(LL& x)
{
char ch;
int sign=;
while(blank(ch=nc()));
if(IOerror) return ;
if(ch=='-') sign=-,ch=nc();
for(x=ch-''; (ch=nc())>=''&&ch<=''; x=x*+ch-'');
x*=sign;
return ;
}
}
using namespace FastIO; const int N=2e6+; int a[N],b[N]; int solve(int n)
{
for(int i=;i<n;i++) read(a[i]),a[i+n]=a[i];
for(int i=;i<n;i++) read(b[i]),b[i+n]=b[i];
int ret=,fuck=;
int sum1=,sum2=,be=;
for(int i=;i<*n&&be<n;i++)
{
sum1+=a[i];
sum2+=a[i]-b[i];
if(sum2<||i-be+==n)
{
if(sum1>fuck) ret=be,fuck=sum1;
sum1=sum2=;
be=i+;
}
}
return ret;
} int main()
{
// freopen("test.in","r",stdin);
int n;
while(read(n))
printf("%d\n",solve(n));
}

最新文章

  1. 与资源库同步时,我的svn报错 Previous operation has not finished; run &#39;cleanup&#39; if it was interrupted
  2. UITableViewDataSource协议
  3. 解决R速度太慢问题
  4. iOS Block传值
  5. C# --2007Access链接字符串
  6. Wincap安装出现“error opening file for writing wpcap.dll”之解决办法
  7. windows下修改mysql用户名和密码
  8. Excel下用SQL语句实现AVEDEV函数功能
  9. Java基础知识强化之多线程笔记06:Lock接口 (区别于Synchronized块)
  10. PHP性能分析
  11. Spring 3 调度器示例 —— JDK 定时器和 Quartz 展示
  12. php 排序
  13. 独立安装WAMP
  14. Python 项目实践三(Web应用程序)第二篇
  15. (双指针) leetcode 27. Remove Element
  16. mybatis 详解------动态SQL
  17. (转)ElasticSearch教程——汇总篇
  18. Linux中OBS在Wayland环境下黑屏只显示鼠标的应对措施
  19. Anaconda详细安装使用教程
  20. Oracle中append与Nologging

热门文章

  1. 熟练使用jquery ui / easyui的各种组件设计网页界面
  2. ngTemplateOutlet递归的问题
  3. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_04 IO字节流_11_字节输入流一次读取多个字节
  4. windows7 玩 WinKawaks kof2002为什么提示couldn&#39;t initialise DirectSound?
  5. usb接口类型 简单分类辨识
  6. python+selenium链接对象操作
  7. python基础-9.1 面向对象进阶 super 类对象成员 类属性 私有属性 查找源码类对象步骤 类特殊成员 isinstance issubclass 异常处理
  8. ceph部署-集群建立
  9. BP神经网络反向传播之计算过程分解(详细版)
  10. flume 进阶