Submission #3596661


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;
int n,k,A[li],pre[li],fe[li+1005],cev;
vector< pair<int,int> > v;
void update(int x){
	for(int i=x;i<=n+1;i+=(i&-i)) fe[i]++; 
}
int que(int x){
	int res=0;
	for(int i=x;i>=1;i-=(i&-i)) res+=fe[i];
	return res;
}
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) {scanf("%d",&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("%d\n",cev);
	return 0;
}

Submission Info

Submission Time
Task E - Meaningful Mean
User Faruk372742
Language C++14 (GCC 5.4.1)
Score 0
Code Size 822 Byte
Status WA
Exec Time 50 ms
Memory 4336 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:22:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&k);
                      ^
./Main.cpp:23:42: 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("%d",&A[i]);A[i]-=k;}
                                          ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 3
AC × 7
WA × 16
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 WA 40 ms 4336 KB
b06 AC 35 ms 4336 KB
b07 WA 49 ms 4336 KB
b08 WA 49 ms 4336 KB
b09 WA 38 ms 4336 KB
b10 WA 45 ms 4336 KB
b11 AC 1 ms 256 KB
b12 WA 1 ms 256 KB
b13 WA 17 ms 1912 KB
b14 WA 48 ms 4336 KB
b15 AC 31 ms 4336 KB
b16 WA 48 ms 4336 KB
b17 WA 48 ms 4336 KB
b18 WA 48 ms 4336 KB
b19 WA 49 ms 4336 KB
b20 WA 50 ms 4336 KB
b21 WA 42 ms 4336 KB
b22 WA 48 ms 4336 KB
b23 WA 48 ms 4336 KB