Submission #1062449

# Submission time Handle Problem Language Result Execution time Memory
1062449 2024-08-17T07:10:09 Z Faisal_Saqib The Big Prize (IOI17_prize) C++17
20 / 100
1 ms 424 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vll vector<ll>
#define all(x) begin(x),end(x)
#define pb push_back

std::vector<int> ask(int i);

int find_best(int n)
{
    int ans=-1;
    int i=0;
    auto it1=ask(0);
    if((it1[1]+it1[0])==0)
        return 0;
    while(1)
    {
        // cout<<"Starting from "<<i<<endl;
        int s=i,e=n;
        auto lasp=it1;
        while(s+1<e){
            int mid=(s+e)/2;
            auto it=ask(mid);
            // cout<<"Checking "<<mid<<endl;
            // cout<<it1[0]<<' '<<it1[1]<<endl;
            // cout<<it[0]<<' '<<it[1]<<endl;
            if((it1[0]==it[0] and it1[1]==it[1]))
            {
                s=mid;
            }
            else{
                int cur_sum=it[0]+it[1];
                int back_sum=it1[0]+it1[1];
                // We want to know if there is any element greater than i in the [i,mid]
                if(back_sum<cur_sum)
                {
                    s=mid;
                }
                else{
                    e=mid;
                    lasp=it;                    
                }

            }
            // if((it[0]+it[1])!=((it1[0]+it1[1])))
            // {
            //     e=mid;
            // }
            // else{
            //     // if max(a1,a2,a3,..,an) <= k  
            //     // if this is the case
            //     // then it1[1]==it[1]
            //     // also it1[0]==it[0]
            //     s=mid;

            // }
        }
        // cout<<"Solved for "<<i<<' '<<s<<' '<<e<<endl;
        if(e==n)
        {
            break;
        }
        i=e;
        it1=lasp;
    }
    return i;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:13:9: warning: unused variable 'ans' [-Wunused-variable]
   13 |     int ans=-1;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 424 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 356 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 1 ms 344 KB answer is not correct
12 Halted 0 ms 0 KB -