Submission #1689923


Source Code Expand

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class BIT{
	public:
	//[1,i]
	int n;
	vi bit;
//	int bit[MAZ_N+1];
	BIT(int size){
		n=size;
		bit=vi(n+1);
	}
	int query(int i){//sum
		int s=0;
		while(i>0){
			s+=bit[i];
			i-=i&-i;
		}
		return s;
	}
	void add(int i,int x){
		while(i<=n){
			bit[i]+=x;
			i+=i&-i;
		}
	}
};
int main(){
	ll n,m;
	cin>>n>>m;
	vp in(n+1);
	rep(i,n)cin>>in[i+1].first;
	rep(i,n+1)in[i].second=i;
	rep(i,n)in[i+1].first+=in[i].first;
	rep(i,n)in[i+1].first-=(i+1)*m;
	vp t=in;
	sort(all(t));
	vi w(n+1);
	rep(i,n+1)w[lower_bound(all(t),in[i])-t.begin()]=i;
//	rep(i,n+1)cout<<" "<<w[i];cout<<endl;
	BIT bit(n+1);
	ll out=0;
	rep(i,n+1){
		out+=bit.query(1+w[i]);
		bit.add(1+w[i],1);
	}
	cout<<out<<endl;
}









Submission Info

Submission Time
Task E - Meaningful Mean
User ixmel_rd
Language C++14 (GCC 5.4.1)
Score 600
Code Size 2137 Byte
Status AC
Exec Time 124 ms
Memory 9600 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 23
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 116 ms 9600 KB
b06 AC 104 ms 9600 KB
b07 AC 124 ms 9600 KB
b08 AC 124 ms 9600 KB
b09 AC 92 ms 9600 KB
b10 AC 96 ms 9600 KB
b11 AC 1 ms 256 KB
b12 AC 2 ms 256 KB
b13 AC 42 ms 3584 KB
b14 AC 120 ms 9600 KB
b15 AC 60 ms 9600 KB
b16 AC 106 ms 9600 KB
b17 AC 120 ms 9600 KB
b18 AC 120 ms 9600 KB
b19 AC 104 ms 9600 KB
b20 AC 123 ms 9600 KB
b21 AC 111 ms 9600 KB
b22 AC 121 ms 9600 KB
b23 AC 120 ms 9600 KB