hdu 6205 card card card 尺取+超神读入挂
题没啥好说的
我就是想把读入挂记录一下
update(2017-10-03)
把读入挂加上了调试
1 #include<bits/stdc++.h> 2 #define cl(a,b) memset(a,b,sizeof(a)) 3 #define debug(a) cerr<<#a<<"=="<<a<<endl 4 using namespace std; 5 typedef long long ll; 6 typedef pair<int,int> pii; 7 8 const int maxn=1e6+10; 9 10 int n; 11 int a[maxn*2]; 12 int b[maxn*2]; 13 14 #define JUDGE 15 16 #ifdef DEBUG 17 inline bool read(int &ret) 18 { 19 if(scanf("%d",&ret)==EOF) return false; 20 return true; 21 } 22 #endif DEBUG 23 24 #ifdef JUDGE 25 namespace fastIO { 26 #define BUF_SIZE 100000 27 //fread -> read 28 bool IOerror = 0; 29 inline char nc() { 30 static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE; 31 if(p1 == pend) { 32 p1 = buf; 33 pend = buf + fread(buf, 1, BUF_SIZE, stdin); 34 if(pend == p1) { 35 IOerror = 1; 36 return -1; 37 } 38 } 39 return *p1++; 40 } 41 inline bool blank(char ch) { 42 return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; 43 } 44 inline bool read(int &x) { 45 char ch; 46 while(blank(ch = nc())); 47 if(IOerror) 48 return false; 49 for(x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0'); 50 return true; 51 } 52 #undef BUF_SIZE 53 }; 54 using namespace fastIO; 55 #endif JUDGE 56 57 int chiqu(int n) 58 { 59 int sum=0,mx=0,ans=0; 60 for(int l=1,r=1; l<=n&&r<=n;) 61 { 62 if(sum>0) sum+=(a[r]-b[r++]); 63 if(r-l+1>=mx) 64 { 65 mx=r-l+1; 66 ans=l-1; 67 } 68 if(sum<=0) sum-=(a[l]-b[l++]); 69 } 70 return ans; 71 } 72 73 int main() 74 { 75 while(read(n)) 76 { 77 for(int i=1; i<=n; i++) read(a[i]); 78 for(int i=1; i<=n; i++) read(b[i]); 79 for(int i=1; i<=n; i++) a[i+n]=a[i],b[i+n]=b[i]; 80 int ans=chiqu(2*n); 81 // debug(ans); 82 printf("%d\n",ans); 83 } 84 return 0; 85 }/* 86 87 5 88 4 6 2 8 4 89 1 5 7 9 2 90 91 */
转载于:https://www.cnblogs.com/general10/p/7502667.html
hdu 6205 card card card 尺取+超神读入挂相关推荐
- [sd card] sd card初始化流程
以SD 3.0为例. 建议先参考<[sd card] SD card初始化时的总线设置>. 一.sd card初始化流程思路说明 通过<SD_Ver3.00_Final_090416 ...
- [sd card] SD card初始化时的总线设置
============================================================== 零.在sd card初始化过程中,对于bus主要设置以下东西 1.时钟,输 ...
- 【POJ - 3320 】Jessica's Reading Problem (尺取,哈希)
题干: Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam i ...
- 【尺取或dp】codeforces C. An impassioned circulation of affection
http://codeforces.com/contest/814/problem/C [题意] 给定一个长度为n的字符串s,一共有q个查询,每个查询给出一个数字m和一个字符ch,你的操作是可以改变字 ...
- 洛谷 - P1381 - 单词背诵 - 哈希 - 尺取
https://www.luogu.org/problemnew/show/P1381 字符串匹配,用哈希总没有错的. 然后就是尺取了,题目要求首先尽可能多覆盖,那么每次尾巴往后面长. 一开始先找到第 ...
- POJ 3320 Jessica's Reading Problem (尺取)
Description 给出一段长度为\(n\)的整数序列,求包含所有出现过的数的连续区间的最小长度. Input 第一行给出序列长度\(n\),第二行给出\(n\)个整数,表示这个序列.\(n \l ...
- 部分和问题 (dfs搜索 尺取)
部分和问题 给定整数a1, a2, a3, a4, .......... , an ,判断是否可以从中取出若干个数,使得他们的和恰好为k . 1 <= n <= 20 测试数 ...
- Innumerable Ancestors 尺取 dfs序 lca
给一棵树,m次查询,每次查询给两个集合,从这两个集合中分别选一个结点,使得这两个结点的lca的深度最大 考虑dfs序为3, 4, 5的三个结点,3和4的lca深度一定大于等于3和5的lca深度 所以可 ...
- Codeforces Round #321 (Div. 2) B. Kefa and Company (尺取)
排序以后枚举尾部.尺取,头部单调,维护一下就好. 排序O(nlogn),枚举O(n) #include<bits/stdc++.h> using namespace std; typede ...
最新文章
- C 实现Mysql增量备份_window下mysql数据库增量备份实现教程
- 开发一个自己的 CSS 框架(二)
- html 静态资源缓存时间,.htaccess设置静态资源缓存(即浏览器缓存)
- 为什么Node约定,回调函数的第一个参数必须是err(如果没有错误该参数就是null)?...
- POJ3070 Fibonacci(矩阵快速幂)
- Java死锁示例–如何分析死锁情况
- Linux 简单打印日志(二)
- Redis内存回收策略
- (新聞) 友達光電 A+種子暑期實習計畫 埋下希望的光電種子 (日記)
- linux awk 脚本格式,偷偷学习shell脚本之awk编辑器
- 毕设日志——Linux软连接的建立与删除
- MySql中 DELIMITER
- php ActiveMQ的安装与使用
- Jquery 图片走马灯效果原理
- 社区发现(二)--GN
- 信息安全工程师 学习笔记 完结
- 史蒂夫·乔布斯谈生命中最重要的东西
- java floor(),Java floor()用法及代码示例
- 信奥中的数学:斐波那契数列
- 【JavaScript】延时器定时器使用