Submission #1062483

# Submission time Handle Problem Language Result Execution time Memory
1062483 2024-08-17T07:51:11 Z Faisal_Saqib The Big Prize (IOI17_prize) C++17
90 / 100
62 ms 428 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);
    while(1)
    {
        // cout<<"Starting from "<<i<<endl;
        int s=i,e=n;
        auto lasp=it1;
        if(lasp[0]==0 and lasp[1]==0)
            return i;
        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)
                {
                    // it is smaller than current element
                    // can't  solve from here
                    // ll rp=rand()%2;
                    // if(rp)
                    // s=mid;
                    // Recursively call for both side
                    // or maybe stop binary search
                    e=i+1;
                    lasp=ask(i+1);
                    break;
                }
                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 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 428 KB Output is correct
9 Correct 1 ms 344 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 420 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 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 3 ms 420 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 9 ms 424 KB Output is correct
16 Partially correct 38 ms 344 KB Partially correct - number of queries: 7332
17 Correct 0 ms 344 KB Output is correct
18 Partially correct 47 ms 344 KB Partially correct - number of queries: 8608
19 Correct 0 ms 344 KB Output is correct
20 Correct 9 ms 344 KB Output is correct
21 Correct 21 ms 344 KB Output is correct
22 Correct 3 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 22 ms 344 KB Output is correct
26 Correct 14 ms 340 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Partially correct 62 ms 344 KB Partially correct - number of queries: 8169
29 Partially correct 27 ms 344 KB Partially correct - number of queries: 6207
30 Partially correct 41 ms 344 KB Partially correct - number of queries: 8551
31 Correct 1 ms 344 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 15 ms 424 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 9 ms 344 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 0 ms 428 KB Output is correct
39 Correct 21 ms 344 KB Output is correct
40 Partially correct 40 ms 344 KB Partially correct - number of queries: 7305
41 Partially correct 27 ms 428 KB Partially correct - number of queries: 5148
42 Partially correct 25 ms 344 KB Partially correct - number of queries: 5148
43 Correct 21 ms 344 KB Output is correct
44 Correct 16 ms 344 KB Output is correct
45 Correct 14 ms 340 KB Output is correct
46 Correct 0 ms 424 KB Output is correct
47 Correct 16 ms 344 KB Output is correct
48 Partially correct 36 ms 348 KB Partially correct - number of queries: 6364
49 Correct 3 ms 344 KB Output is correct
50 Partially correct 49 ms 348 KB Partially correct - number of queries: 8606
51 Correct 24 ms 348 KB Output is correct
52 Correct 1 ms 344 KB Output is correct
53 Correct 1 ms 428 KB Output is correct
54 Correct 17 ms 344 KB Output is correct
55 Correct 0 ms 428 KB Output is correct
56 Partially correct 53 ms 344 KB Partially correct - number of queries: 8607
57 Partially correct 39 ms 344 KB Partially correct - number of queries: 6287
58 Partially correct 39 ms 344 KB Partially correct - number of queries: 6395
59 Partially correct 33 ms 344 KB Partially correct - number of queries: 5148
60 Correct 21 ms 344 KB Output is correct
61 Correct 1 ms 344 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 2 ms 344 KB Output is correct
64 Correct 1 ms 344 KB Output is correct
65 Correct 1 ms 344 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 4 ms 424 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 0 ms 344 KB Output is correct
71 Partially correct 38 ms 344 KB Partially correct - number of queries: 8729
72 Correct 3 ms 344 KB Output is correct
73 Partially correct 44 ms 344 KB Partially correct - number of queries: 8617
74 Partially correct 48 ms 344 KB Partially correct - number of queries: 8668
75 Correct 1 ms 340 KB Output is correct
76 Partially correct 32 ms 344 KB Partially correct - number of queries: 7458
77 Partially correct 46 ms 340 KB Partially correct - number of queries: 8621
78 Correct 3 ms 344 KB Output is correct
79 Correct 16 ms 344 KB Output is correct
80 Partially correct 44 ms 344 KB Partially correct - number of queries: 8622
81 Partially correct 52 ms 340 KB Partially correct - number of queries: 8633
82 Partially correct 54 ms 344 KB Partially correct - number of queries: 8560
83 Correct 1 ms 344 KB Output is correct
84 Partially correct 27 ms 344 KB Partially correct - number of queries: 7056
85 Partially correct 47 ms 344 KB Partially correct - number of queries: 8611
86 Correct 22 ms 344 KB Output is correct
87 Correct 2 ms 344 KB Output is correct
88 Correct 16 ms 344 KB Output is correct
89 Correct 18 ms 344 KB Output is correct
90 Correct 1 ms 344 KB Output is correct
91 Correct 13 ms 344 KB Output is correct
92 Correct 17 ms 344 KB Output is correct
93 Correct 2 ms 344 KB Output is correct
94 Correct 2 ms 344 KB Output is correct
95 Correct 2 ms 344 KB Output is correct
96 Correct 2 ms 344 KB Output is correct
97 Correct 1 ms 344 KB Output is correct