# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
246446 |
2020-07-09T10:57:22 Z |
bibabas |
Vudu (COCI15_vudu) |
C++14 |
|
762 ms |
55164 KB |
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define vi vector<ll>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ld long double
#define pii pair<ll, ll>
#define mt make_tuple
#define mn(a, b) a = min(a, b)
#define mx(a, b) a = max(a, b)
using namespace std;
const ll INF = (ll)2e9;
const ll inf = (ll)2e18;
const ld eps = (ld)1e-8;
const ll mod = (ll)10007;
const ll MAXN = (ll)1e4 + 1;
const ll MAXC = (ll)1e6 + 1;
const ll MAXE = (ll)1000;
const ll MAXLOG = 21;
const ll maxlen = (ll)1e5;
const ll asci = (ll)256;
const ll block = 480;
const ld PI = acos(-1);
const ld e = 2.7182818284;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<
pii,
null_type,
less<pii>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
template <class T>
istream& operator >>(istream &in, vector<T> &arr){
for (T &cnt : arr) {
in >> cnt;
}
return in;
};
struct stree{
vi t;
stree (ll n) {
t.resize(4 * n);
}
void upd(ll v, ll tl, ll tr, ll pos) {
if (tl + 1 == tr) return void(t[v]++);
ll tm = (tl + tr) / 2;
if (pos < tm) upd(2 * v, tm, tr, pos);
else upd(2 * v + 1, tm, tr, pos);
t[v] = t[2 * v] + t[2 * v + 1];
}
ll ask(ll v, ll tl, ll tr, ll l, ll r) {
if (l <= tl && tr <= r) return t[v];
if (tl >= r || l >= tr) return 0;
ll tm = (tl + tr) / 2;
return ask(2 * v, tl, tm, l, r) + ask(2 * v + 1, tm, tr, l, r);
}
};
void solve() {
ll n; cin >> n;
vi a(n); cin >> a;
ll p; cin >> p;
vi pref(n + 1);
for (ll i = 0; i < n; ++i) a[i] -= p;
for (ll i = 0; i < n; ++i) pref[i + 1] = pref[i] + a[i];
vi vals = pref;
sort(all(vals));
vals.resize(unique(all(vals)) - vals.begin());
stree t(vals.size());
ll ans = 0;
for (ll i = 0; i <= n; ++i) {
ans += t.ask(1, 0, vals.size(), 0, upper_bound(all(vals), pref[i]) - vals.begin());
t.upd(1, 0, vals.size(), lower_bound(all(vals), pref[i]) - vals.begin());
}
cout << ans << "\n";
}
signed main() {
srand(time(0));
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#endif
cout.precision(30);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
768 KB |
Output isn't correct |
2 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
3 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
4 |
Incorrect |
762 ms |
53344 KB |
Output isn't correct |
5 |
Incorrect |
395 ms |
30456 KB |
Output isn't correct |
6 |
Incorrect |
641 ms |
47352 KB |
Output isn't correct |
7 |
Incorrect |
651 ms |
49244 KB |
Output isn't correct |
8 |
Incorrect |
615 ms |
42792 KB |
Output isn't correct |
9 |
Incorrect |
734 ms |
55164 KB |
Output isn't correct |
10 |
Incorrect |
638 ms |
47864 KB |
Output isn't correct |