0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

#2392. 「JOISC 2017 Day 1」烟花棒

https://loj.ac/s/1697303
This commit is contained in:
Baoshuo Ren 2023-02-09 09:13:18 +08:00
parent 9c964d4687
commit 457e358658
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
146 changed files with 550 additions and 0 deletions

115
LibreOJ/2392/2392.cpp Normal file
View File

@ -0,0 +1,115 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
int n, k, t;
long long x[N], a[N];
bool check(int v) {
for (int i = 1; i <= n; i++) {
a[i] = x[i] - 2ll * v * t * i;
}
if (a[n] > a[1]) {
return false;
}
int l = k, r = k;
for (int i = k - 1; i >= 1; i--) {
if (a[l] - a[i] <= 0) l = i;
}
for (int i = k + 1; i <= n; i++) {
if (a[i] - a[r] <= 0) r = i;
}
int l1 = k, r1 = k;
while (l < l1 || r1 < r) {
int nl = l1, nr = r1;
bool flag = false;
while (l < nl && a[r1] - a[nl - 1] <= 0) {
if (a[l1] - a[--nl] <= 0) break;
}
if (nl < l1 && a[l1] - a[nl] <= 0) {
l1 = nl;
flag = true;
}
while (nr < r && a[nr + 1] - a[l1] <= 0) {
if (a[++nr] - a[r1] <= 0) break;
}
if (r1 < nr && a[nr] - a[r1] <= 0) {
r1 = nr;
flag = true;
}
if (!flag) return false;
}
int l2 = 1, r2 = n;
while (l2 < l || r < r2) {
int nl = l2, nr = r2;
bool flag = false;
while (nl < l && a[r2] - a[nl + 1] <= 0) {
if (a[++nl] - a[l2] >= 0) break;
}
if (l2 < nl && a[nl] - a[l2] >= 0) {
l2 = nl;
flag = true;
}
while (r < nr && a[nr - 1] - a[l2] <= 0) {
if (a[r2] - a[--nr] >= 0) break;
}
if (nr < r2 && a[r2] - a[nr] >= 0) {
r2 = nr;
flag = true;
}
if (!flag) return false;
}
return true;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k >> t;
for (int i = 1; i <= n; i++) {
cin >> x[i];
}
int l = 0, r = 1e9,
res = 0;
while (l <= r) {
int mid = (l + r) >> 1;
if (check(mid)) {
r = mid - 1;
res = mid;
} else {
l = mid + 1;
}
}
cout << res << endl;
return 0;
}

BIN
LibreOJ/2392/data/01-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-08.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-08.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-09.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-09.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/01-21.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-08.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-08.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-09.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-09.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/02-19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-08.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-08.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-09.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-09.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2392/data/03-10.in (Stored with Git LFS) Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More