Submission #835784

# Submission time Handle Problem Language Result Execution time Memory
835784 2023-08-23T19:55:27 Z elkernos Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 212 KB
// clang-format off
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef XOX
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; }
sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
struct { template <class T> operator T() { T x; cin >> x; return x; } } in;
#define endl '\n'
#define pb emplace_back
#define vt vector
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using i64 = long long;
// #define int long long
// clang-format on

int32_t main()
{
    int n = in;
    vector<double> a(n + 1), b(n + 1);
    for(int i = 1; i <= n; i++) a[i] = in, b[i] = in;
    sort(a.begin(), a.end()), sort(b.begin(), b.end());
    reverse(a.begin() + 1, a.end()), reverse(b.begin() + 1, b.end());
    for(int i = 1; i <= n; i++) a[i] += a[i - 1], b[i] += b[i - 1];
    debug() << imie(a) imie(b);
    double ans = 0;
    for(int rep : {0 ,1}) {
        int j = 0;
        for(int i = 0; i <= n; i++) {
            // take i times a
            while(j + 1 <= n && b[j + 1] <= a[i]) j++;
            ans = max(ans, b[j] - (i + j));
        }
        swap(a, b);
    }
    cout << ans << endl;
}

Compilation message

sure.cpp: In function 'int32_t main()':
sure.cpp:48:13: warning: unused variable 'rep' [-Wunused-variable]
   48 |     for(int rep : {0 ,1}) {
      |             ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -