#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define N 200100
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
#define mp(a,b) make_pair((a),(b))
#define INF 2147000000
using namespace std;
int l[N],r[N],n,k,tot[N];
long long a[N],s[N];
long long ans=0;
pair<int,int> b[N];
long long calc(int l,int r,int x)
{
if (l>r) return 0;
return (long long)(upper_bound(b,b+n+2,mp(x,r))-lower_bound(b,b+n+2,mp(x,l)));
}
void solve(int x)
{
ans--;l[x]++;r[x]--;
if (l[x]==x)
{
int t=s[x-1]+a[x];
if (t>=k) t-=k;
ans+=calc(x,r[x],t);
}else
Views:
320
|
Added by:
dhy0077
|
Date:
09.23.2013