#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+55;
ll a[N];
ll sum[N];
multiset < ll > st;
int main()
{
ios::sync_with_stdio(false);
int n;
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
int P;
cin>>P;
for(int i=0;i<n;i++)
{
sum[i]=a[i]-P;
if(i)
sum[i]+=sum[i-1];
st.insert(sum[i]);
}
ll ans=0;
ll x=0;
for(int i=0;i<n;i++)
{
ans+=distance(st.lower_bound(x),st.end());
st.erase(st.find(sum[i]));
x+=a[i]-P;
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
111 ms |
888 KB |
Output is correct |
2 |
Correct |
106 ms |
760 KB |
Output is correct |
3 |
Correct |
77 ms |
788 KB |
Output is correct |
4 |
Execution timed out |
1073 ms |
66560 KB |
Time limit exceeded |
5 |
Execution timed out |
1074 ms |
39888 KB |
Time limit exceeded |
6 |
Execution timed out |
1077 ms |
62240 KB |
Time limit exceeded |
7 |
Execution timed out |
1069 ms |
64760 KB |
Time limit exceeded |
8 |
Execution timed out |
1072 ms |
56124 KB |
Time limit exceeded |
9 |
Execution timed out |
1075 ms |
66560 KB |
Time limit exceeded |
10 |
Execution timed out |
1074 ms |
63072 KB |
Time limit exceeded |