Submission #950099

# Submission time Handle Problem Language Result Execution time Memory
950099 2024-03-20T05:21:48 Z vjudge1 Vudu (COCI15_vudu) C++17
112 / 140
468 ms 65536 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>

template<class S, class T>
bool chmin(S& a, const T& b) {
  return a > b ? (a = b) == b : false;
}
template<class S, class T>
bool chmax(S& a, const T& b) {
  return a < b ? (a = b) == b : false;
}

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n; cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  int p; cin >> p;
  ordered_set st;
  int res = 0, sum = 0;
  st.insert(0);
  for (int i = 1; i <= n; ++i) {
    sum += a[i];
    res += size(st) - st.order_of_key(p * i - sum);
    st.insert(p * i - sum);
  }
  cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 860 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Runtime error 468 ms 65536 KB Execution killed with signal 9
5 Correct 279 ms 38936 KB Output is correct
6 Correct 395 ms 60692 KB Output is correct
7 Correct 405 ms 63140 KB Output is correct
8 Correct 366 ms 54612 KB Output is correct
9 Runtime error 388 ms 65536 KB Execution killed with signal 9
10 Correct 438 ms 61268 KB Output is correct