Submission #3596662


Source Code Expand

#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 200005
using namespace std;
lo int n,k,A[li],pre[li],fe[li+1005],cev;
vector< pair<lo int,lo int> > v;
void update(int x){
	for(int i=x;i<=n+1;i+=(i&-i)) fe[i]++; 
}
lo int que(lo int x){
	lo int res=0;
	for(int i=x;i>=1;i-=(i&-i)) res+=fe[i];
	return res;
}
int main(){
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++) {scanf("%lld",&A[i]);A[i]-=k;}
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+A[i];
	v.pb(mp(0,0));
	for(int i=1;i<=n;i++){
		v.pb(mp(pre[i],i));
	}
	sort(v.begin(),v.end());
	for(int i=0;i<(int)v.size();i++){
		update(v[i].se+1);
		if(v[i].se==0) continue;
		cev+=que(v[i].se);
	}
	printf("%lld\n",cev);
	return 0;
}

Submission Info

Submission Time
Task E - Meaningful Mean
User Faruk372742
Language C++14 (GCC 5.4.1)
Score 600
Code Size 848 Byte
Status AC
Exec Time 54 ms
Memory 9328 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:22:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n,&k);
                          ^
./Main.cpp:23:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) {scanf("%lld",&A[i]);A[i]-=k;}
                                            ^

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 2 ms 2304 KB
a02 AC 2 ms 2304 KB
a03 AC 2 ms 2304 KB
b04 AC 2 ms 2304 KB
b05 AC 41 ms 8172 KB
b06 AC 37 ms 8172 KB
b07 AC 54 ms 8816 KB
b08 AC 54 ms 8172 KB
b09 AC 40 ms 8816 KB
b10 AC 45 ms 8816 KB
b11 AC 2 ms 2304 KB
b12 AC 2 ms 2304 KB
b13 AC 18 ms 4980 KB
b14 AC 46 ms 8172 KB
b15 AC 32 ms 8172 KB
b16 AC 39 ms 8172 KB
b17 AC 46 ms 8304 KB
b18 AC 47 ms 8944 KB
b19 AC 37 ms 8172 KB
b20 AC 50 ms 9200 KB
b21 AC 43 ms 8172 KB
b22 AC 53 ms 9328 KB
b23 AC 52 ms 8944 KB