码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 6205(尺取法)2017 ACM/ICPC Asia Regional Shenyang Online

时间:2017-09-13 21:21:27      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:stdio.h   end   exp   algorithm   --   http   name   space   sig   

题目链接

emmmm...思路是群里群巨聊天讲这题是用尺取法.....emmm然后就没难度了,不过时间上3000多,有点.....盗了个低配本的读入挂发现就降到2800左右,

翻了下,发现神犇Claris280MS秒过.......%%%

#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <ctype.h>
//******************************************************
#define lrt (rt*2)
#define rrt  (rt*2+1)
#define LL long long
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define exp 1e-8
//***************************************************
//***********************************
#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair

#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
//#define FastRead      ios_base::sync_with_stdio(0);cin.tie(0)
#define FastRead        ios::sync_with_stdio(false);
#define CasePrint       pc(‘C‘); pc(‘a‘); pc(‘s‘); pc(‘e‘); pc(‘ ‘); write(qq++,false); pc(‘:‘); pc(‘ ‘)
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define FOR(I,A,B)      for(int I = (A); I <= (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)
#define REP(I,N)        FOR(I,1,N)
using namespace std;
const int maxn=2e6+50;
int n,a[maxn],b[maxn];
int main()
{
    while(~scanf("%d",&n))
    {
        REP(i,n) scanf("%d",&a[i]),a[i+n]=a[i];
        REP(i,n) scanf("%d",&b[i]),b[i+n]=b[i];
        int sum=a[1]-b[1],f=1;
        FOR(i,2,2*n)
        {
            sum+=(a[i]-b[i]);
            if(i-f+1 == n)  break;
            if(sum<0)   f=i+1,sum=0;
        }
        printf("%d\n",f-1);
    }
    return 0;
}

 

HDU 6205(尺取法)2017 ACM/ICPC Asia Regional Shenyang Online

标签:stdio.h   end   exp   algorithm   --   http   name   space   sig   

原文地址:http://www.cnblogs.com/weimeiyuer/p/7517555.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!