0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:48:48 +00:00

#2600. 「NOIP2011」聪明的质监员

https://loj.ac/s/1314652
This commit is contained in:
Baoshuo Ren 2021-12-02 20:44:32 +08:00
parent d100f0e79f
commit 074289c77d
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
41 changed files with 174 additions and 0 deletions

54
LibreOJ/2600/2600.cpp Normal file
View File

@ -0,0 +1,54 @@
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
int n, m, l, r, w[200005], v[200005];
long long s, y, sum, ans, fn[200005], fv[200005];
std::pair<int, int> q[200005];
bool check(int x) {
y = sum = 0;
fn[0] = fv[0] = 0;
for (int i = 1; i <= n; i++) {
fn[i] = fn[i - 1];
fv[i] = fv[i - 1];
if (w[i] >= x) {
fn[i] += 1;
fv[i] += v[i];
}
}
for (int i = 1; i <= m; i++) {
y += (fn[q[i].second] - fn[q[i].first - 1]) * (fv[q[i].second] - fv[q[i].first - 1]);
}
sum = std::abs(y - s);
return y > s;
}
int main() {
ans = std::numeric_limits<long long>::max();
l = std::numeric_limits<int>::max();
r = std::numeric_limits<int>::min();
cin >> n >> m >> s;
for (int i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
l = std::min(l, w[i]);
r = std::max(r, w[i]);
}
for (int i = 1; i <= m; i++) {
cin >> q[i].first >> q[i].second;
}
l -= 1, r += 2;
while (l <= r) {
int mid = l + r >> 1;
if (check(mid)) {
l = mid + 1;
} else {
r = mid - 1;
}
ans = std::min(ans, sum);
}
cout << ans << endl;
return 0;
}

BIN
LibreOJ/2600/data/qc1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc10.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc11.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc12.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc13.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc14.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc15.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc16.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc17.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc18.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc19.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc20.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc3.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc4.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc5.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc6.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc7.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc8.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc9.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2600/data/qc9.in (Stored with Git LFS) Normal file

Binary file not shown.