Submission #962257

# Submission time Handle Problem Language Result Execution time Memory
962257 2024-04-13T09:48:08 Z LucaIlie Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5;
const long long MAX_P = 1e15;
const int DEC = 1e4;
int a[MAX_N + 1], b[MAX_N + 1];
long long sa[MAX_N + 1], sb[MAX_N + 1];

int main() {
    int n;

    cin >> n;
    for ( int i = 1; i <= n; i++ ) {
        double x, y;
        cin >> x >> y;
        a[i] = x * DEC;
        b[i] = y * DEC;
    }

    sort( a + 1, a + 1 + n );
    reverse( a + 1, a + 1 + n );
    sort( b + 1, b + 1 + n );
    reverse( b + 1, b + 1 + n );
    for ( int i = 1; i <= n; i++ ) {
        sa[i] = sa[i - 1] + a[i];
        sb[i] = sb[i - 1] + b[i];
        printf( "%d %d\n", sa[i], sb[i] );
    }

    long long l = 0, r = MAX_P;
    while ( r - l > 1 ) {
        long long p = (l + r) / 2;

        bool isPos = false;
        for ( int i = 0; i <= n; i++ ) {
            int j = min( (long long)n, max( 0LL, (sa[i] - i * DEC - p) / DEC ) );
            if ( min( sa[i], sb[j] ) - (i + j) * DEC >= p )
                isPos = true;
        }

        if ( isPos )
            l = p;
        else
            r = p;
    }

    cout << (double)l / DEC;

    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:29:19: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   29 |         printf( "%d %d\n", sa[i], sb[i] );
      |                  ~^        ~~~~~
      |                   |            |
      |                   int          long long int
      |                  %lld
sure.cpp:29:22: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
   29 |         printf( "%d %d\n", sa[i], sb[i] );
      |                     ~^            ~~~~~
      |                      |                |
      |                      int              long long int
      |                     %lld
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -