# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
88414 | Koschei | Vudu (COCI15_vudu) | C++17 | 372 ms | 66560 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int n;
long long c;
long long p, r, a[1000000];
vector< pair<long long, int> > prefiks_sume;
int tree[1000005] = {0};
void add(int x)
{
while (x < 1000005)
{
tree[x]++;
x += x & (-x);
}
}
long long gets(int x)
{
long long s = 0;
while (x)
{
s += tree[x];
x -= x & (-x);
}
return s;
}
int main()
{
prefiks_sume.push_back(make_pair(0, 1));
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%lld", &a[i]);
}
scanf("%lld", &p);
for (int i = 0; i < n; i++)
{
r += a[i] - p;
prefiks_sume.push_back(make_pair(r, i+2));
}
sort(prefiks_sume.begin(), prefiks_sume.end());
for (int i = 0; i <= n; i++)
{
c += gets(prefiks_sume[i].second-1);
add(prefiks_sume[i].second);
}
printf("%lld", c);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |