# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
931504 | 2024-02-22T01:05:50 Z | TIN | Vudu (COCI15_vudu) | C++17 | 452 ms | 65536 KB |
#include <bits/stdc++.h> using namespace std; #define FNAME "test" typedef long long ll; const int N = 1e6 + 5; int n; ll a[N]; ll P; vector<ll> pre; ll mx; ll ans; struct Fenwick { int n; vector<ll> f; Fenwick(int _n) { n = _n; f.resize(n + 5, 0LL); } void set(int i) { for (; i <= n; i += i & (-i)) f[i]++; } ll get(int i) { ll r = 0; for (; i > 0; i -= i & (-i)) r += f[i]; return r; } }; void Task() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 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()); mx = (int) b.size() + 1; 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 + 1); 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 | Correct | 3 ms | 1012 KB | Output is correct |
2 | Correct | 2 ms | 604 KB | Output is correct |
3 | Correct | 2 ms | 604 KB | Output is correct |
4 | Runtime error | 370 ms | 65536 KB | Execution killed with signal 9 |
5 | Correct | 263 ms | 40784 KB | Output is correct |
6 | Correct | 452 ms | 61152 KB | Output is correct |
7 | Correct | 434 ms | 65536 KB | Output is correct |
8 | Correct | 406 ms | 55308 KB | Output is correct |
9 | Runtime error | 300 ms | 65536 KB | Execution killed with signal 9 |
10 | Correct | 445 ms | 61808 KB | Output is correct |