# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
967730 | jadai007 | Vudu (COCI15_vudu) | C++14 | 257 ms | 63160 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k,arr[1010000], ans, qs[1010000];
vector<int> vc;
struct FenwickTree {
vector<int> fwt;
FenwickTree(int sz) {
fwt.resize(sz + 10000);
}
int query(int idx) {
int ans = 0;
for (idx++; idx > 0; idx -= idx & -idx) ans += fwt[idx];
return ans;
}
void update(int idx) {
for (idx++; idx < fwt.size(); idx += idx & -idx) fwt[idx]++;
}
} fwt(1e6);
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for(int i = 1; i<=n; ++i) cin >> arr[i];
for(int i = 1; i<=n; ++i) qs[i] = qs[i - 1] + arr[i];
cin >> k;
for(int i = 0; i<=n; ++i) vc.push_back(qs[i] - k*i);
sort(vc.begin(), vc.end());
vc.erase(unique(vc.begin(), vc.end()));
for(int i = 0; i<=n; ++i){
int idx = lower_bound(vc.begin(), vc.end(), qs[i] - k*i) - vc.begin();
ans += fwt.query(idx);
fwt.update(idx);
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |