Submission #951846

# Submission time Handle Problem Language Result Execution time Memory
951846 2024-03-22T20:22:34 Z MohamedAhmed04 Vudu (COCI15_vudu) C++14
126 / 140
538 ms 65536 KB
#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
1 Correct 3 ms 856 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 538 ms 65536 KB Output is correct
5 Correct 246 ms 36904 KB Output is correct
6 Correct 427 ms 57228 KB Output is correct
7 Correct 414 ms 62060 KB Output is correct
8 Correct 372 ms 51676 KB Output is correct
9 Runtime error 419 ms 65536 KB Execution killed with signal 9
10 Correct 416 ms 59032 KB Output is correct