Submission #1027438

#TimeUsernameProblemLanguageResultExecution timeMemory
1027438vjudge1Sure Bet (CEOI17_sure)C++14
100 / 100
61 ms4588 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define double long double
const int MAXN = 100086;

int main() {
    int n;
    vector<double> a(MAXN), b(MAXN);
    double sum1 = 0, sum2 = 0, maxx = 0;

    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%Lf %Lf", &a[i], &b[i]);

    sort(a.begin() + 1, a.end(), greater<double>());
    sort(b.begin() + 1, b.end(), greater<double>());

    int r = 1;
    for (int l = 1; l <= n; ++l) {
        sum1 += a[l];
        double res = 0;

        while (true) {
            res = min(sum1, sum2) - l - r + 1;
            if (min(sum1, sum2 + b[r]) - l - r > res) {
                sum2 += b[r++];
                if (r > n) break;
            } else {
                break;
            }
        }

        maxx = max(maxx, min(sum1, sum2) - l - r + 1);
    }

    printf("%.4Lf", maxx);
    return 0;
}

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
sure.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%Lf %Lf", &a[i], &b[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...