# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
571190 |
2022-06-01T12:40:35 Z |
piOOE |
Sure Bet (CEOI17_sure) |
C++17 |
|
98 ms |
6732 KB |
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int)size(x))
#define all(x) begin(x), end(x)
#define trace(x) cout << #x << ": " << (x) << endl;
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; }
template<typename T>
bool ckmn(T &x, T y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template<typename T>
bool ckmx(T &x, T y) {
if (x < y) {
x = y;
return true;
}
return false;
}
const int N = 100001, infI = 1e9 + 7;
const ll infL = 3e18;
double a[N], b[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
}
sort(a, a + n, greater<>());
sort(b, b + n, greater<>());
double ans = 0, suma = 0, sumb = 0;
vector<tuple<double, int, int>> v(2 * n);
for (int i = 0; i < n; ++i) {
suma += a[i];
sumb += b[i];
v[i] = {suma, i + 1, 0};
v[i + n] = {sumb, i + 1, 1};
}
sort(all(v));
int mn[2] = {infI, infI};
for (int i = 2 * n - 1; i > -1; --i) {
ckmx(ans, get<0>(v[i]) - get<1>(v[i]) - mn[get<2>(v[i]) ^ 1]);
ckmn(mn[get<2>(v[i])], get<1>(v[i]));
}
cout << fixed << setprecision(4) << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
332 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 |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
332 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 |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
332 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 |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
98 ms |
6308 KB |
Output is correct |
18 |
Correct |
88 ms |
6356 KB |
Output is correct |
19 |
Correct |
96 ms |
6296 KB |
Output is correct |
20 |
Correct |
91 ms |
6288 KB |
Output is correct |
21 |
Correct |
97 ms |
6732 KB |
Output is correct |
22 |
Correct |
92 ms |
6352 KB |
Output is correct |
23 |
Correct |
90 ms |
6296 KB |
Output is correct |
24 |
Correct |
96 ms |
6308 KB |
Output is correct |
25 |
Correct |
88 ms |
6308 KB |
Output is correct |
26 |
Correct |
98 ms |
6732 KB |
Output is correct |