# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
924394 | 2024-02-09T02:33:32 Z | TIN | Vudu (COCI15_vudu) | C++17 | 431 ms | 65536 KB |
#include <bits/stdc++.h> using namespace std; #define FNAME "test" typedef long long ll; const int N = 1e7; int n; ll a[N]; ll P; vector<ll> pre; ll ans; struct Fenwick { int n; vector<ll> f; Fenwick(int n) : n(n), f(n + 1, 0) {} void set(int i) { for (; i <= n; i += i & (-i)) f[i]++; return; } ll get(int i) { ll r = 0; for (; i >= 1; i -= i & (-i)) r += f[i]; return r; } }; void Task() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout << fixed << setprecision(9); if (fopen(FNAME".inp","r")) { freopen(FNAME".inp","r",stdin); freopen(FNAME".out","w",stdout); } } void compress(vector<ll>& v) { set<ll> s(v.begin(), v.end()); vector<ll> b(s.begin(), s.end()); for (ll &x : v) x = lower_bound(b.begin(), b.end(), x) - b.begin() + 1; return; } void Solve() { //Your Code cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; cin >> P; pre.resize(n + 1); pre[0] = 0; for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + (a[i] - P); compress(pre); Fenwick BIT(N); ans = 0; for (int i = 1; i <= n; i++) { BIT.set(pre[i - 1]); ans += BIT.get(pre[i]); } cout << ans << '\n'; return; } int main() { Task(); Solve(); cerr << "\nTime run: " << 1000*clock()/CLOCKS_PER_SEC << "ms"; return 37^37; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 23 ms | 65536 KB | Execution killed with signal 9 |
2 | Runtime error | 14 ms | 65536 KB | Execution killed with signal 9 |
3 | Runtime error | 15 ms | 65536 KB | Execution killed with signal 9 |
4 | Runtime error | 357 ms | 65536 KB | Execution killed with signal 9 |
5 | Runtime error | 248 ms | 65536 KB | Execution killed with signal 9 |
6 | Runtime error | 431 ms | 65536 KB | Execution killed with signal 9 |
7 | Runtime error | 406 ms | 65536 KB | Execution killed with signal 9 |
8 | Runtime error | 380 ms | 65536 KB | Execution killed with signal 9 |
9 | Runtime error | 338 ms | 65536 KB | Execution killed with signal 9 |
10 | Runtime error | 416 ms | 65536 KB | Execution killed with signal 9 |