Submission #205454

# Submission time Handle Problem Language Result Execution time Memory
205454 2020-02-29T00:55:24 Z oscarsierra12 The Big Prize (IOI17_prize) C++14
20 / 100
7 ms 1932 KB
#include "prize.h"
#include <bits/stdc++.h>

#define ff    first
#define ss    second

using namespace std ;

typedef pair<int,int>   pii ;


map <int,int> mp ;
int numLess [ 7 ] ;
pii dp [ 200010 ] ;
int val [ 7 ] ;

int find_best(int n) {
    int cnt = 1 ;
    memset ( dp, -1, sizeof dp ) ;
    //while ( 1 ) {
        int lw = 0, hg = n-1 ;
        while ( lw < hg ) {
            int mid = (lw+hg)/2 ;
            if ( dp[mid].ff == -1 ) {
                vector <int> ans = ask(mid) ;
                dp[mid].ff = ans[0] ;
                dp[mid].ss = ans[1] ;
            }
            pii v = dp[mid] ;
            if ( mp[v.ff+v.ss] == 0 ) {
                mp[v.ff+v.ss] = cnt ;
                val[cnt] = v.ff+v.ss ;
                cnt++ ;
            }
            if ( v.ss - numLess[mp[v.ff+v.ss]] == 0 )
                hg = mid ;
            else lw = mid+1 ;
        }
        if ( dp[hg].ff == -1 ) {
            vector <int> ans = ask(hg) ;
            dp[hg].ff = ans[0] ;
            dp[hg].ss = ans[1] ;
        }
        pii v = dp[hg] ;
        if ( v.ff + v.ss == 0 ) return hg ;
        --hg ;
        if ( dp[hg].ff == -1 ) {
            vector <int> ans = ask(hg) ;
            dp[hg].ff = ans[0] ;
            dp[hg].ss = ans[1] ;
        }
        v = dp[hg] ;
        for ( int i = 1 ; i < 6 ; ++i )
            if ( val[i] >= v.ff+v.ss ) numLess[i] += v.ss ;
    //}
    return n ;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1848 KB Output is correct
2 Correct 6 ms 1836 KB Output is correct
3 Correct 6 ms 1784 KB Output is correct
4 Correct 6 ms 1784 KB Output is correct
5 Correct 6 ms 1932 KB Output is correct
6 Correct 6 ms 1784 KB Output is correct
7 Correct 6 ms 1928 KB Output is correct
8 Correct 6 ms 1784 KB Output is correct
9 Correct 7 ms 1848 KB Output is correct
10 Correct 6 ms 1784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1932 KB Output is correct
2 Correct 6 ms 1852 KB Output is correct
3 Correct 6 ms 1932 KB Output is correct
4 Correct 6 ms 1852 KB Output is correct
5 Correct 7 ms 1852 KB Output is correct
6 Correct 6 ms 1836 KB Output is correct
7 Correct 6 ms 1784 KB Output is correct
8 Correct 6 ms 1836 KB Output is correct
9 Correct 6 ms 1864 KB Output is correct
10 Correct 6 ms 1912 KB Output is correct
11 Incorrect 6 ms 1856 KB Integer 200000 violates the range [0, 199999]
12 Halted 0 ms 0 KB -