Submission #947983

# Submission time Handle Problem Language Result Execution time Memory
947983 2024-03-17T11:05:45 Z vjudge306 Vudu (COCI15_vudu) C++17
42 / 140
965 ms 64808 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;
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nn "\n"
#define x_x ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define intt int _; cin >> _; while (_--)
#define emp push_back
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define ld long double
#define A first
#define B second
//#define int long long
typedef long long ll;
const ld eps = 1e-27;
// diff between decimals 0.000000001 mt19937 mt(time(nullptr));

int main() {

    x_x
int n; cin>>n; ll p, sm=0, ar[n];
for(auto&i:ar)cin>>i;
cin>>p; ordered_set s;
ll ans=0; s.insert(ans);
for (ll i=1; i<=n; i++) {
    sm+=ar[i-1]; ll x=p*i; x=sm-x;
    ans+=s.order_of_key(x+1); x=-p*i; x+=sm; s.insert(x);
}
// s.insert(1); s.insert(2); s.insert(3); cout<<s.order_of_key(5);
cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 860 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Incorrect 853 ms 62632 KB Output isn't correct
5 Incorrect 369 ms 35664 KB Output isn't correct
6 Incorrect 721 ms 55828 KB Output isn't correct
7 Incorrect 783 ms 57908 KB Output isn't correct
8 Incorrect 602 ms 50016 KB Output isn't correct
9 Incorrect 965 ms 64808 KB Output isn't correct
10 Incorrect 728 ms 56400 KB Output isn't correct