hdu 6205: card card card【输入挂】
2024-09-05 22:37:34
感谢 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));
}
最新文章
- 与资源库同步时,我的svn报错 Previous operation has not finished; run &#39;cleanup&#39; if it was interrupted
- UITableViewDataSource协议
- 解决R速度太慢问题
- iOS Block传值
- C# --2007Access链接字符串
- Wincap安装出现“error opening file for writing wpcap.dll”之解决办法
- windows下修改mysql用户名和密码
- Excel下用SQL语句实现AVEDEV函数功能
- Java基础知识强化之多线程笔记06:Lock接口 (区别于Synchronized块)
- PHP性能分析
- Spring 3 调度器示例 —— JDK 定时器和 Quartz 展示
- php 排序
- 独立安装WAMP
- Python 项目实践三(Web应用程序)第二篇
- (双指针) leetcode 27. Remove Element
- mybatis 详解------动态SQL
- (转)ElasticSearch教程——汇总篇
- Linux中OBS在Wayland环境下黑屏只显示鼠标的应对措施
- Anaconda详细安装使用教程
- Oracle中append与Nologging
热门文章
- 熟练使用jquery ui / easyui的各种组件设计网页界面
- ngTemplateOutlet递归的问题
- 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_04 IO字节流_11_字节输入流一次读取多个字节
- windows7 玩 WinKawaks kof2002为什么提示couldn&#39;t initialise DirectSound?
- usb接口类型 简单分类辨识
- python+selenium链接对象操作
- python基础-9.1 面向对象进阶 super 类对象成员 类属性 私有属性 查找源码类对象步骤 类特殊成员 isinstance issubclass 异常处理
- ceph部署-集群建立
- BP神经网络反向传播之计算过程分解(详细版)
- flume 进阶