Submission #380580

#TimeUsernameProblemLanguageResultExecution timeMemory
380580Aryan_RainaVudu (COCI15_vudu)C++14
42 / 140
1098 ms59116 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> oset; #define int long long #define ld long double #define ar array const int INF = 1e17; const int MOD = 1e9; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; vector<int> a(n); for (int &i : a) cin>>i; oset s; s.insert(0); int p; cin>>p; int psum = 0; int ans = 0; for (int i = 0; i < n; i++) { psum += a[i]; int diff = psum - (i+1)*p; ans += s.order_of_key(diff+1); s.insert(diff); } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...