# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
951845 | MohamedAhmed04 | Vudu (COCI15_vudu) | C++17 | 622 ms | 65536 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 ;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ;
const int MAX = 1e6 + 10 ;
int n , p ;
int arr[MAX] ;
int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
cin>>n ;
for(int i = 1 ; i <= n ; ++i)
cin>>arr[i] ;
cin>>p ;
for(int i = 1 ; i <= n ; ++i)
arr[i] -= p ;
ordered_set< pair<long long, int> >s ;
s.insert({0 , 0}) ;
long long sum = 0 , ans = 0 ;
for(int i = 1 ; i <= n ; ++i)
{
sum += arr[i] ;
ans += s.order_of_key({sum+1 , -1}) ;
s.insert({sum , i});
}
return cout<<ans<<"\n" , 0 ;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |