| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 313881 | BeanZ | Vudu (COCI15_vudu) | C++14 | 380 ms | 24024 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 1e6 + 5;
ll a[N], st[N];
ll n;
void add(ll x){
for (; x <= (n + 1); x += (x & -x)){
st[x]++;
}
}
ll get(ll x){
ll res = 0;
for (; x > 0; x -= (x & -x)){
res = res + st[x];
}
return res;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("A.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
ll p;
cin >> p;
for (int i = 1; i <= n; i++) a[i] -= p;
vector<ll> val;
ll sum = 0;
val.push_back(sum);
for (int i = 1; i <= n; i++){
sum = sum + a[i];
val.push_back(sum);
}
sort(val.begin(), val.end());
val.resize(unique(val.begin(), val.end()) - val.begin());
add(lower_bound(val.begin(), val.end(), 0) - val.begin() + 1);
sum = 0;
ll ans = 0;
for (int i = 1; i <= n; i++){
sum = sum + a[i];
ll id = lower_bound(val.begin(), val.end(), sum) - val.begin() + 1;
ans = ans + get(id);
add(id);
}
cout << ans;
}
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
