# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
256595 | amiratou | Vudu (COCI15_vudu) | C++14 | 1084 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.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set= tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
ordered_set<pair<ll,int> > myset;
int A[1000001],n,k;
ll h,ans;
int32_t main(){
boost;
cin>>n;
//freopen(".in","r",stdin);
for (int i = 0; i < n; ++i)
cin>>A[i];
cin>>k;
for (int i = 0; i < n; ++i)
{
h+=A[i]-k;
myset.insert({h,i});
}
h=0;
for (int i = 0; i < n; ++i)
{
ans+=sz(myset)-myset.order_of_key({h,-1});
h+=A[i]-k;
myset.erase({h,i});
}
cout<<ans<<"\n";
return 0;
}
//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |