제출 #1062449

#제출 시각아이디문제언어결과실행 시간메모리
1062449Faisal_Saqib커다란 상품 (IOI17_prize)C++17
20 / 100
1 ms424 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'int find_best(int)':
prize.cpp:13:9: warning: unused variable 'ans' [-Wunused-variable]
   13 |     int ans=-1;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...