# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
252699 | islingr | Vudu (COCI15_vudu) | C++14 | 249 ms | 15992 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;
using ll = int64_t;
const int N = 1 << 20;
ll a[N], t[N];
ll solve(int l, int r) {
if (r - l == 1) return 0;
int m = (l + r) / 2;
ll res = solve(l, m) + solve(m, r);
int i = l, j = m, k = l;
while (i < m && j < r)
if (a[i] <= a[j]) t[k++] = a[i++], res += r - j;
else t[k++] = a[j++];
while (i < m) t[k++] = a[i++];
while (j < r) t[k++] = a[j++];
rep(i, l, r) a[i] = t[i];
return res;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
rep(i, 0, n) cin >> a[i + 1];
int P; cin >> P;
rep(i, 0, n) a[i + 1] -= P;
rep(i, 0, n) a[i + 1] += a[i];
cout << solve(0, n + 1);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |