# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
679821 |
2023-01-09T10:37:40 Z |
peijar |
Sure Bet (CEOI17_sure) |
C++17 |
|
2000 ms |
6324 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
namespace std {
template <typename T> ostream &operator<<(ostream &out, const vector<T> &vec) {
out << "[";
for (int i = 0; i < (int)vec.size(); ++i) {
out << vec[i];
if (i + 1 < (int)vec.size())
out << ", ";
}
return out << "]";
}
} // namespace std
void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
cout << ' ' << H;
dbg_out(T...);
}
#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
signed main(void) {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<double> a(n), b(n);
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
vector<double> valA(a.begin(), a.end());
vector<double> valB(b.begin(), b.end());
valA.resize(unique(valA.begin(), valA.end()) - valA.begin());
valB.resize(unique(valB.begin(), valB.end()) - valB.begin());
int cntA = valA.size();
int cntB = valB.size();
vector<double> suffA(n + 1), suffB(n + 1);
for (int i = n - 1; i >= 0; --i) {
suffA[i] = suffA[i + 1] + a[i];
suffB[i] = suffB[i + 1] + b[i];
}
double sol = 0;
for (int takeA = 0; takeA <= cntA; ++takeA) {
for (int takeB = 0; takeB <= cntB; ++takeB) {
double fromA = takeA == 0 ? 1e9 : valA[cntA - takeA];
double fromB = takeB == 0 ? 1e9 : valB[cntB - takeB];
int loA = lower_bound(a.begin(), a.end(), fromA) - a.begin();
int loB = lower_bound(b.begin(), b.end(), fromB) - b.begin();
double cost = 2 * n - loA - loB;
sol = max(sol, min(suffA[loA] - cost, suffB[loB] - cost));
}
}
printf("%.4lf", sol);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
50 ms |
360 KB |
Output is correct |
13 |
Correct |
49 ms |
364 KB |
Output is correct |
14 |
Correct |
51 ms |
368 KB |
Output is correct |
15 |
Correct |
57 ms |
336 KB |
Output is correct |
16 |
Correct |
52 ms |
368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
50 ms |
360 KB |
Output is correct |
13 |
Correct |
49 ms |
364 KB |
Output is correct |
14 |
Correct |
51 ms |
368 KB |
Output is correct |
15 |
Correct |
57 ms |
336 KB |
Output is correct |
16 |
Correct |
52 ms |
368 KB |
Output is correct |
17 |
Execution timed out |
2062 ms |
6324 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |