Submission #1082338

# Submission time Handle Problem Language Result Execution time Memory
1082338 2024-08-31T07:49:00 Z MMihalev The Big Prize (IOI17_prize) C++14
90 / 100
51 ms 2408 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include "prize.h"
using namespace std;
const int MAX_N=2e5+4;
int asked[MAX_N][2];
bool used[MAX_N];
int qq;
pair<int,int>query(int pos)
{
    if(used[pos])return {asked[pos][0],asked[pos][1]};

    if(qq>10000)while(1);
    used[pos]=1;
    qq++;
    auto ve=ask(pos);
    asked[pos][0]=ve[0];
    asked[pos][1]=ve[1];
    return {ve[0],ve[1]};
}
int find_best(int n)
{
    int prevpos=-1;
    int qq=500;
    int big=-1e9;
    while(qq--)
    {
        prevpos++;
        auto cur=query(prevpos);
        int all=cur.first+cur.second;
        if(all==0)return prevpos;
        big=max(big,all);
    }
    while(1)
    {
        prevpos++;
        auto cur=query(prevpos);
        int all=cur.first+cur.second;
        if(all==big)
        {
            int l=prevpos,r=n-1;
            while(l<=r)
            {
                int mid=(l+r)/2;
                auto cur2=query(mid);
                if(cur2==cur)
                {
                    prevpos=mid;
                    l=mid+1;
                }
                else r=mid-1;
            }
        }
        else
        {
            if(all==0)return prevpos;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 2 ms 448 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 2 ms 452 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 4 ms 856 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 5 ms 1368 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 8 ms 1112 KB Output is correct
16 Partially correct 25 ms 2136 KB Partially correct - number of queries: 7209
17 Correct 2 ms 344 KB Output is correct
18 Partially correct 34 ms 2212 KB Partially correct - number of queries: 8370
19 Correct 2 ms 344 KB Output is correct
20 Correct 12 ms 856 KB Output is correct
21 Correct 17 ms 1624 KB Output is correct
22 Correct 5 ms 856 KB Output is correct
23 Correct 3 ms 456 KB Output is correct
24 Correct 3 ms 352 KB Output is correct
25 Correct 26 ms 1744 KB Output is correct
26 Correct 27 ms 1624 KB Output is correct
27 Correct 3 ms 600 KB Output is correct
28 Partially correct 47 ms 2308 KB Partially correct - number of queries: 7897
29 Partially correct 35 ms 1900 KB Partially correct - number of queries: 6135
30 Partially correct 50 ms 2124 KB Partially correct - number of queries: 8299
31 Correct 2 ms 344 KB Output is correct
32 Correct 4 ms 1112 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 20 ms 1468 KB Output is correct
35 Correct 4 ms 856 KB Output is correct
36 Correct 11 ms 1112 KB Output is correct
37 Correct 4 ms 600 KB Output is correct
38 Correct 2 ms 344 KB Output is correct
39 Correct 19 ms 1624 KB Output is correct
40 Partially correct 43 ms 1992 KB Partially correct - number of queries: 7167
41 Partially correct 32 ms 1696 KB Partially correct - number of queries: 5230
42 Partially correct 24 ms 1640 KB Partially correct - number of queries: 5230
43 Correct 19 ms 1616 KB Output is correct
44 Correct 25 ms 1468 KB Output is correct
45 Correct 14 ms 1440 KB Output is correct
46 Correct 3 ms 344 KB Output is correct
47 Correct 22 ms 1480 KB Output is correct
48 Partially correct 29 ms 1872 KB Partially correct - number of queries: 6326
49 Correct 5 ms 1108 KB Output is correct
50 Partially correct 34 ms 2236 KB Partially correct - number of queries: 8370
51 Correct 21 ms 1512 KB Output is correct
52 Correct 2 ms 344 KB Output is correct
53 Correct 2 ms 596 KB Output is correct
54 Correct 29 ms 1616 KB Output is correct
55 Correct 2 ms 344 KB Output is correct
56 Partially correct 44 ms 2128 KB Partially correct - number of queries: 8365
57 Partially correct 40 ms 1872 KB Partially correct - number of queries: 6230
58 Partially correct 30 ms 1868 KB Partially correct - number of queries: 6311
59 Partially correct 23 ms 1748 KB Partially correct - number of queries: 5227
60 Correct 25 ms 1612 KB Output is correct
61 Correct 2 ms 600 KB Output is correct
62 Correct 3 ms 344 KB Output is correct
63 Correct 3 ms 600 KB Output is correct
64 Correct 5 ms 600 KB Output is correct
65 Correct 3 ms 344 KB Output is correct
66 Correct 5 ms 344 KB Output is correct
67 Correct 3 ms 344 KB Output is correct
68 Correct 2 ms 344 KB Output is correct
69 Correct 5 ms 344 KB Output is correct
70 Correct 3 ms 344 KB Output is correct
71 Partially correct 40 ms 2052 KB Partially correct - number of queries: 8277
72 Correct 4 ms 1368 KB Output is correct
73 Partially correct 48 ms 2168 KB Partially correct - number of queries: 8149
74 Partially correct 43 ms 2336 KB Partially correct - number of queries: 8218
75 Correct 3 ms 600 KB Output is correct
76 Partially correct 37 ms 2144 KB Partially correct - number of queries: 7126
77 Partially correct 34 ms 2228 KB Partially correct - number of queries: 8419
78 Correct 7 ms 1212 KB Output is correct
79 Correct 20 ms 1992 KB Output is correct
80 Partially correct 51 ms 2408 KB Partially correct - number of queries: 8429
81 Partially correct 50 ms 2140 KB Partially correct - number of queries: 8403
82 Partially correct 50 ms 2200 KB Partially correct - number of queries: 8291
83 Correct 3 ms 856 KB Output is correct
84 Partially correct 40 ms 2156 KB Partially correct - number of queries: 6963
85 Partially correct 48 ms 2384 KB Partially correct - number of queries: 8374
86 Correct 2 ms 344 KB Output is correct
87 Correct 3 ms 344 KB Output is correct
88 Correct 3 ms 344 KB Output is correct
89 Correct 3 ms 344 KB Output is correct
90 Correct 3 ms 344 KB Output is correct
91 Correct 3 ms 344 KB Output is correct
92 Correct 3 ms 456 KB Output is correct
93 Correct 4 ms 1368 KB Output is correct
94 Correct 6 ms 1112 KB Output is correct
95 Correct 5 ms 1184 KB Output is correct
96 Correct 5 ms 1112 KB Output is correct
97 Correct 2 ms 344 KB Output is correct