0%

CCPC 2020 秦皇岛 E - Exam Results

题目

Professor Alex is preparing an exam for his students now.

There will be $n$ students participating in this exam. If student $i$ has a good mindset, he/she will perform well and get $a_i$ points. Otherwise, he/she will get $b_i$ points. So it is impossible to predict the exam results. Assume the highest score of these students is $x$ points. The students with a score of no less than $x⋅p\%$ will pass the exam.

Alex needs to know what is the maximum number of students who can pass the exam in all situations. Can you answer his question?

思路

(待完善)

AC代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } }_io;
typedef long long ll; typedef long double db;

const ll maxn = 2e5 + 5;
array<pair<ll, ll>, maxn> a;
array<ll, maxn> count1;
vector<pair<ll, ll>> b;

int main()
{
ll T, test = 1;
cin >> T;
while (T--)
{
ll n, p;
cin >> n >> p;

b.clear();
for (ll i = 0; i < n; ++i)
{
cin >> a[i].first >> a[i].second;
if (a[i].first > a[i].second) swap(a[i].first, a[i].second);
b.push_back({ a[i].first,i });
b.push_back({ a[i].second,i });
}
sort(a.begin(), a.begin() + n);
sort(b.begin(), b.end());

memset(&count1, 0, 8 * n);

ll cnt = 0, ans = 0, j = 0;
for (ll i = 0; i < b.size(); ++i)
{
++count1[b[i].second];
if (count1[b[i].second] == 1) ++cnt;
if (b[i].first < a[n - 1].first) continue;

while (j <= i && b[j].first * 100 < b[i].first * p)
{
--count1[b[j].second];
if (!count1[b[j++].second]) --cnt;
}
ans = max(ans, cnt);
}

cout << "Case #" << test++ << ": " << ans << endl;
}
return 0;
}