# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
410109 | rqi | Vudu (COCI15_vudu) | C++14 | 659 ms | 65540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ins insert
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
const int mx = 1000005;
int N;
ll a[mx];
ll P;
int main(){
cin.tie(0)->sync_with_stdio(0);
cin >> N;
for(int i = 1; i <= N; i++){
cin >> a[i];
}
cin >> P;
for(int i = 1; i <= N; i++){
a[i]-=P;
}
for(int i = 1; i <= N; i++){
a[i]+=a[i-1];
}
Tree<pair<ll, int>> t;
t.ins(mp(0, 0));
ll ans = 0;
for(int i = 1; i <= N; i++){
ll val = ll(t.ook(mp(a[i], N+5)));
//cout << "i, val: " << i << " " << val << "\n";
ans+=val;
t.ins(mp(a[i], i));
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |