Submission #648970

# Submission time Handle Problem Language Result Execution time Memory
648970 2022-10-08T21:12:26 Z tvladm2009 Vudu (COCI15_vudu) C++14
0 / 140
521 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;

template<class T> using oset = tree<T, null_type, std::less<T>, rb_tree_tag,tree_order_statistics_node_update>;

using ll = long long;
#define int ll

int const nmax = 1000000;

int v[5 + nmax], sp[5 + nmax];

signed main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);

  int n, p;
  std::cin >> n;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  std::cin >> p;
  for(int i = 1;i <= n; i++) {
    v[i] -= p;
    sp[i] = sp[i - 1] + v[i];
  }

  oset<int> s;
  s.insert(0);
  int ans = 0;
  for(int i = 1;i <= n; i++) {
    ans += s.order_of_key(sp[i]);
    s.insert(sp[i]);
  }
  std::map<int, int> mp;
  mp[0]++;
  for(int i = 1;i <= n; i++) {
    ans += mp[sp[i]];
    mp[sp[i]]++;
  }
  std::cout << ans;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1364 KB Output isn't correct
2 Incorrect 4 ms 1108 KB Output isn't correct
3 Incorrect 4 ms 944 KB Output isn't correct
4 Runtime error 521 ms 65536 KB Execution killed with signal 9
5 Runtime error 403 ms 65536 KB Execution killed with signal 9
6 Runtime error 479 ms 65536 KB Execution killed with signal 9
7 Runtime error 429 ms 65536 KB Execution killed with signal 9
8 Runtime error 473 ms 65536 KB Execution killed with signal 9
9 Runtime error 447 ms 65536 KB Execution killed with signal 9
10 Runtime error 481 ms 65536 KB Execution killed with signal 9