Submission #976181

# Submission time Handle Problem Language Result Execution time Memory
976181 2024-05-06T09:14:00 Z LucaIlie The Big Prize (IOI17_prize) C++17
20 / 100
48 ms 1976 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5;
int ans[MAX_N][2];

bool found = false;
int pos;

pair<int, int> askk( int i ) {
    if ( ans[i][0] == -1 ) {
        auto x = ask( i );
        ans[i][0] = x[0];
        ans[i][1] = x[1];
    }
    return { ans[i][0], ans[i][1] };
}

void solve( int l, int r ) {
    if ( found )
        return;

    if ( l > r )
        return;

    int mid = (l + r) / 2;
    auto [a, b] = askk( mid );

    if ( a == 0 && b == 0 ) {
        found = true;
        pos = mid;
        return;
    }

    if ( a < b ) {
        solve( mid + 1, r );
        solve( l, mid - 1 );
    } else {
        solve( l, mid - 1 );
        solve( mid + 1, r );
    }
}

int find_best( int n ) {
    for( int i = 0; i < n; i++ )
        ans[i][0] = ans[i][1] = -1;

    solve( 0, n - 1 );

    return pos;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 1 ms 1880 KB Output is correct
3 Correct 1 ms 1880 KB Output is correct
4 Correct 1 ms 1976 KB Output is correct
5 Correct 2 ms 1888 KB Output is correct
6 Correct 2 ms 1880 KB Output is correct
7 Correct 1 ms 1972 KB Output is correct
8 Correct 1 ms 1928 KB Output is correct
9 Correct 2 ms 1880 KB Output is correct
10 Correct 2 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1976 KB Output is correct
2 Correct 2 ms 1880 KB Output is correct
3 Correct 1 ms 1880 KB Output is correct
4 Correct 1 ms 1880 KB Output is correct
5 Correct 1 ms 1972 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 1 ms 1972 KB Output is correct
9 Correct 2 ms 1880 KB Output is correct
10 Correct 1 ms 1880 KB Output is correct
11 Incorrect 48 ms 1880 KB Incorrect
12 Halted 0 ms 0 KB -