Submission #865395

#TimeUsernameProblemLanguageResultExecution timeMemory
865395vjudge1Sure Bet (CEOI17_sure)C++17
0 / 100
1 ms2396 KiB
#include <bits/stdc++.h> #define pb push_back #define all(q) q.begin (), q.end () #define ll long long #define f first #define s second using namespace std; const ll MOD = 1e9 + 7; const ll inf = 1e9 + 1; const ll INF = 1e18 + 1; const ll N = 2e6 + 1; const int k = 15; double a[N], b[N]; void solve (){ int n; cin >> n; for (int i = 1; i <= n; ++i){ cin >> a[i] >> b[i]; // a[i] -= 1; // b[i] -= 1; } sort (a + 1, a + 1 + n); sort (b + 1, b + 1 + n); reverse (a + 1, a + 1 + n); reverse (b + 1, b + 1 + n); // cout << '\n'; // for (int i = 1; i <= n; ++i) cout << a[i] << ' ' << b[i] << '\n'; // cout << '\n'; int l = 1, r = 1, t = 0; double q = 0, w = 0, ans = 0; while (l != n + 1 && r != n + 1){ while (l != n + 1 && q <= w){ // cout << l << ' '; q += a[l]; ++t; ++l; // cout << q << ' ' << w << '\n'; ans = max (ans, min (q, w) - t); } while (r != n + 1 && q >= w){ // cout << r << ' '; w += b[r]; ++r; ++t; // cout << q << ' ' << w << '\n'; ans = max (ans, min (q, w) - t); } } cout << fixed << setprecision (5); cout << ans; } main (){ ios_base::sync_with_stdio (0); cin.tie (0); // freopen("guard.in", "r", stdin); // freopen("guard.out", "w", stdout); ll t = 1; // cin >> t; for (ll i = 1; i <= t; ++i){ // cout << "Case " << i << ':' << '\n'; solve (); // cout << '\n'; } }

Compilation message (stderr)

sure.cpp:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   57 | main (){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...