Submission #848356

#TimeUsernameProblemLanguageResultExecution timeMemory
848356vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
313 ms12392 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...