# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
848356 |
2023-09-12T08:31:48 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
313 ms |
12392 KB |
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
#define ll long long
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, a, b) for (int i = (a); i >= (b); --i)
#define pi pair<int,int>
#define ple tuple<int,int,int>
#define fi first
#define se second
#define ii make_pair
#define isz(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define heap_max(a) priority_queue<a>
#define heap_max(a) priority_queue<a,vector<a>,greater<a>>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T>
//using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 1e6 + 10;
long double p1[N], p2[N], a[N], b[N];
int n;
#define ld long double
ld Min (ld a, ld b) {
if (a < b) return a;
return b;
}
ld f (int i, int x) {
return Min(p1[i] - i - x, p2[x] - x - i);
}
int main () {
file("dynamic");
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
FOR(i,1,n) cin >> a[i] >> b[i];
sort(a+1,a+n+1,greater<ld>());
sort(b+1,b+n+1,greater<ld>());
FOR(i,1,n) {
p1[i] = p1[i-1] + a[i];
p2[i] = p2[i-1] + b[i];
}
// cout <<
ld res = 0;
FOR(i,1,n) {
int l=1, r=n;
for (int x = 1; x <= 100; ++x) {
int x1 = l + (r - l) / 3;
int x2 = r - (r - l) / 3;
if (f(i,x1) > f(i,x2)) r = x2;
else l = x1;
}
for (int j = -100; j <= 100; ++j) {
int x = l + j;
if (x < 1 || x > n) continue;
res = max(res, f(i, x));
}
}
// cout << p1[2] << ' ' << p2[1] << endl;
cout << setprecision(4) << fixed << res << '\n';
}
Compilation message
sure.cpp:16: warning: "heap_max" redefined
16 | #define heap_max(a) priority_queue<a,vector<a>,greater<a>>
|
sure.cpp:15: note: this is the location of the previous definition
15 | #define heap_max(a) priority_queue<a>
|
sure.cpp: In function 'int main()':
sure.cpp:4:60: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
4 | #define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:40:7: note: in expansion of macro 'file'
40 | file("dynamic");
| ^~~~
sure.cpp:4:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
4 | #define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:40:7: note: in expansion of macro 'file'
40 | file("dynamic");
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
4 ms |
2396 KB |
Output is correct |
13 |
Correct |
4 ms |
2396 KB |
Output is correct |
14 |
Correct |
4 ms |
2392 KB |
Output is correct |
15 |
Correct |
4 ms |
2392 KB |
Output is correct |
16 |
Correct |
4 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
4 ms |
2396 KB |
Output is correct |
13 |
Correct |
4 ms |
2396 KB |
Output is correct |
14 |
Correct |
4 ms |
2392 KB |
Output is correct |
15 |
Correct |
4 ms |
2392 KB |
Output is correct |
16 |
Correct |
4 ms |
2392 KB |
Output is correct |
17 |
Correct |
306 ms |
12176 KB |
Output is correct |
18 |
Correct |
300 ms |
12112 KB |
Output is correct |
19 |
Correct |
313 ms |
12112 KB |
Output is correct |
20 |
Correct |
306 ms |
12112 KB |
Output is correct |
21 |
Correct |
304 ms |
12368 KB |
Output is correct |
22 |
Correct |
305 ms |
12176 KB |
Output is correct |
23 |
Correct |
303 ms |
12176 KB |
Output is correct |
24 |
Correct |
305 ms |
12392 KB |
Output is correct |
25 |
Correct |
302 ms |
12180 KB |
Output is correct |
26 |
Correct |
307 ms |
12372 KB |
Output is correct |