# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
253630 |
2020-07-28T13:18:33 Z |
Vimmer |
Vudu (COCI15_vudu) |
C++14 |
|
377 ms |
25812 KB |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define pf push_front
#define N 1000050
#define M ll(998244353)
#define inf 1e9 + 1e9
using namespace std;
//using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef short int si;
typedef array <ll, 3> a3;
typedef array <ll, 4> a4;
//typedef tree <ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int t[N];
void upd(int v)
{
for (; v >= 0; v = (v & (v + 1)) - 1) t[v]++;
}
int sm(int v)
{
int ans = 0;
for (; v < N; v = (v | (v + 1))) ans += t[v];
return ans;
}
int main()
{
//freopen("input.txt", "r", stdin); //freopen("output4.txt", "w", stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin >> n;
int a[n];
vector <ll> gr; gr.clear();
for (int i = 0; i < n; i++) cin >> a[i];
ll sum = 0;
int p;
cin >> p;
for (int i = 0; i < n; i++)
{
a[i] -= p;
sum += ll(a[i]);
gr.pb(sum);
}
sort(gr.begin(), gr.end());
sum = 0;
ll ans = 0;
for (int i = 0; i < n; i++)
{
ll need = -a[i];
sum += a[i];
need += sum;
int ind = lower_bound(gr.begin(), gr.end(), need) - gr.begin();
ans += sz(gr) - ind;
ans -= sm(ind);
upd(ind);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
4 |
Incorrect |
377 ms |
24916 KB |
Output isn't correct |
5 |
Incorrect |
197 ms |
11880 KB |
Output isn't correct |
6 |
Incorrect |
318 ms |
14932 KB |
Output isn't correct |
7 |
Incorrect |
325 ms |
18132 KB |
Output isn't correct |
8 |
Incorrect |
284 ms |
13524 KB |
Output isn't correct |
9 |
Incorrect |
366 ms |
25812 KB |
Output isn't correct |
10 |
Incorrect |
322 ms |
16280 KB |
Output isn't correct |