0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 17:38:47 +00:00

P7868 [COCI2015-2016#2] VUDU

https://www.luogu.com.cn/record/76401826
This commit is contained in:
Baoshuo Ren 2022-05-26 10:41:14 +08:00
parent 0f4f1a4fb9
commit cb6341c8ed
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
21 changed files with 116 additions and 0 deletions

56
Luogu/P7868/P7868.cpp Normal file
View File

@ -0,0 +1,56 @@
#include <algorithm>
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e6 + 5;
int n, p, a[N];
long long b[N], ans;
void solve(int l, int r) {
if (l == r) {
if (a[l] >= p) ans++;
return;
}
int mid = l + r >> 1;
solve(l, mid);
solve(mid + 1, r);
b[mid] = a[mid] - p;
for (int i = mid - 1; i >= l; i--) b[i] = b[i + 1] + a[i] - p;
std::sort(b + l, b + mid + 1);
b[mid + 1] = a[mid + 1] - p;
for (int i = mid + 2; i <= r; i++) b[i] = b[i - 1] + a[i] - p;
std::sort(b + mid + 1, b + r + 1);
int i = l, j = r;
while (i <= mid) {
while (j > mid && b[i] + b[j] >= 0) j--;
ans += r - j;
i++;
}
}
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
cin >> p;
solve(1, n);
cout << ans << endl;
return 0;
}

BIN
Luogu/P7868/data/vudu1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu10.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu3.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu4.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu5.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu6.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu7.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu8.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu9.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P7868/data/vudu9.in (Stored with Git LFS) Normal file

Binary file not shown.