标签:long print 记录 ati mem i++ class const cer
题没啥好说的
我就是想把读入挂记录一下
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 namespace fastIO { 15 #define BUF_SIZE 100000 16 //fread -> read 17 bool IOerror = 0; 18 inline char nc() { 19 static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE; 20 if(p1 == pend) { 21 p1 = buf; 22 pend = buf + fread(buf, 1, BUF_SIZE, stdin); 23 if(pend == p1) { 24 IOerror = 1; 25 return -1; 26 } 27 } 28 return *p1++; 29 } 30 inline bool blank(char ch) { 31 return ch == ‘ ‘ || ch == ‘\n‘ || ch == ‘\r‘ || ch == ‘\t‘; 32 } 33 inline void read(int &x) { 34 char ch; 35 while(blank(ch = nc())); 36 if(IOerror) 37 return; 38 for(x = ch - ‘0‘; (ch = nc()) >= ‘0‘ && ch <= ‘9‘; x = x * 10 + ch - ‘0‘); 39 } 40 #undef BUF_SIZE 41 }; 42 using namespace fastIO; 43 44 int chiqu(int n) 45 { 46 int sum=0,mx=0,ans=0; 47 for(int l=1,r=1; l<=n&&r<=n;) 48 { 49 if(sum>0) sum+=(a[r]-b[r++]); 50 if(r-l+1>=mx) 51 { 52 mx=r-l+1; 53 ans=l-1; 54 } 55 if(sum<=0) sum-=(a[l]-b[l++]); 56 } 57 return ans; 58 } 59 60 int main() 61 { 62 while(read(n),!fastIO::IOerror) 63 { 64 for(int i=1; i<=n; i++) read(a[i]); 65 for(int i=1; i<=n; i++) read(b[i]); 66 for(int i=1; i<=n; i++) a[i+n]=a[i],b[i+n]=b[i]; 67 int ans=chiqu(2*n); 68 // debug(ans); 69 printf("%d\n",ans); 70 } 71 return 0; 72 }/* 73 74 5 75 4 6 2 8 4 76 1 5 7 9 2 77 78 */
hdu 6205 card card card 尺取+超神读入挂
标签:long print 记录 ati mem i++ class const cer
原文地址:http://www.cnblogs.com/general10/p/7502667.html