Submission #26965

# Submission time Handle Problem Language Result Execution time Memory
26965 2017-07-07T15:40:31 Z repeating Rice Hub (IOI11_ricehub) C++11
0 / 100
53 ms 15692 KB
#include <bits/stdc++.h>
#include "ricehub.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%I64d",&x)
#define SF2(x,y) scanf("%I64d%I64d",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()
#define MAX_R  1000000

using namespace std;
const long long INF = 1e9+5e8;
const int MX=100009;
int a[MX];
int n,b;
ll seg[MX*4];
ll f[MX*8];
void u(int node,int l,int r,int s,int e,int val){
    if(r<s||e<l)R;
    seg[node]+=f[node]*(r-l+1);
    f[node*2]+=f[node];
    f[node*2+1]+=f[node];
    f[node]=0;
    if(s<=l&&r<=e){
        seg[node]+=val*(r-l+1);
        f[node*2]+=val;
        f[node*2+1]+=val;
        R;
    }
    u(node*2,l,(l+r)/2,s,e,val);
    u(node*2+1,(l+r)/2+1,r,s,e,val);
    seg[node]=seg[node*2]+seg[node*2+1];
}
ll q(int node,int l,int r,int s,int e){
    if(r<s||e<l)R 0;
    seg[node]+=f[node]*(r-l+1);
    f[node*2]+=f[node];
    f[node*2+1]+=f[node];
    f[node]=0;
    if(s<=l&&r<=e)R seg[node];
    ll ret=0;
    ret+=q(node*2,l,(l+r)/2,s,e);
    ret+=q(node*2+1,(l+r)/2+1,r,s,e);
    R ret;
}
void change(int p1,int &p,int p2){
    int mid=(p1+p2)/2;
    if(mid==p)R;
    u(1,0,n-1,0,p,a[p+1]-a[p]);
    u(1,0,n-1,p+1,n-1,a[p]-a[p+1]);
    p++;
}
int solve(){
    for(int i=0;i<n;i++){
        u(1,0,n-1,i,i,a[i]-a[0]);
    }
    int ret=1;
    int p1=0,p2=0,p=0;
    W(p2<n){
        W(q(1,0,n-1,p1,p2)>b){
            cout<<p1<<" "<<p2<<" "<<q(1,0,n-1,p1,p2)<<endl;
            p1++;
            change(p1,p,p2);
        }
//        cout<<p1<<" "<<p2<<endl;
        ret=max(ret,p2-p1+1);
        p2++;
        change(p1,p,p2);
    }
    R ret;
}
int besthub(int r, int L, int X[], long long B)
{
    n=r;
    b=B;
    for(int i=0;i<n;i++){
        a[i]=X[i];
    }
    return solve();
}

//static int r, L;
//static long long B;
//static int X[MAX_R];
//static int solution;
//
//inline
//void my_assert(int e) {if (!e) abort();}
//
//static void read_input()
//{
//  int i;
//  my_assert(3==scanf("%d %d %lld",&r,&L,&B));
//  for(i=0; i<r; i++)
//    my_assert(1==scanf("%d",&X[i]));
//  my_assert(1==scanf("%d",&solution));
//}
//
//int main()
//{
//  int ans;
//  read_input();
//  ans = besthub(r,L,X,B);
//  if(ans==solution)
//    printf("Correct.\n");
//  else
//    printf("Incorrect.  Returned %d instead of %d.\n",ans,solution);
//
//  return 0;
//}
//

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 15692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 15692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 15692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 15692 KB Output isn't correct
2 Halted 0 ms 0 KB -