# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971888 | 2024-04-29T12:45:45 Z | Sunbae | Vudu (COCI15_vudu) | C++17 | 117 ms | 30896 KB |
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int N = 4e5 + 5; int m; ll bit[N], qs[N], P; vector<ll> cp; int pos(ll x){return upper_bound(cp.begin(), cp.end(), x) - cp.begin();} void upd(int i){for(; i<=m; i+=i&-i) ++bit[i];} ll qry(int i){ll res = 0; for(; i; i-=i&-i) res += bit[i]; return res;} signed main(){ int n; scanf("%d", &n); for(int i = 1; i<=n; ++i){ scanf("%lld", qs+i); qs[i] += qs[i-1]; } scanf("%lld", &P); for(ll i = 0; i<=n; ++i) cp.push_back(qs[i] - P*i); sort(cp.begin(), cp.end()); cp.resize(unique(cp.begin(), cp.end()) - cp.begin()); m = cp.size(); upd(pos(0)); ll Ans = 0; for(ll i = 1; i<=n; ++i){ int x = pos(qs[i] - P*i); Ans += qry(x); upd(x); } printf("%lld", Ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2648 KB | Output is correct |
2 | Correct | 2 ms | 2648 KB | Output is correct |
3 | Correct | 2 ms | 2652 KB | Output is correct |
4 | Runtime error | 87 ms | 18908 KB | Execution killed with signal 11 |
5 | Runtime error | 85 ms | 25260 KB | Execution killed with signal 11 |
6 | Runtime error | 71 ms | 18896 KB | Execution killed with signal 11 |
7 | Runtime error | 72 ms | 18772 KB | Execution killed with signal 11 |
8 | Runtime error | 117 ms | 30896 KB | Execution killed with signal 11 |
9 | Runtime error | 73 ms | 18772 KB | Execution killed with signal 11 |
10 | Runtime error | 70 ms | 18772 KB | Execution killed with signal 11 |