# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
961678 | Blagoj | Vudu (COCI15_vudu) | C++17 | 269 ms | 42852 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(), (x).end()
struct FenwickTree {
vector<ll> fwt;
FenwickTree(int sz) {
fwt.resize(sz + 100);
}
int get(int ind) {
ll ans = 0;
for (ind++; ind; ind -= ind & -ind) ans = max(ans, fwt[ind]);
return ans;
}
void update(int ind) {
for (ind++; ind < fwt.size(); ind += ind & -ind) fwt[ind]++;
}
} fwt(1e6);
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, p;
cin >> n;
ll a[n + 1], prf[n + 1];
memset(prf, 0, sizeof(prf));
for (int i = 1; i <= n; i++) {
cin >> a[i];
prf[i] = prf[i - 1] + a[i];
}
cin >> p;
vector<ll> v;
for (int i = 0; i <= n; i++) v.push_back({prf[i] - p * i});
sort(all(v));
v.erase(unique(all(v)), v.end());
ll ans = 0;
for (int i = 0; i <= n; i++) {
int x = lower_bound(all(v), prf[i] - p * i) - v.begin();
ans += fwt.get(x);
fwt.update(x);
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |