Submission #869524

# Submission time Handle Problem Language Result Execution time Memory
869524 2023-11-04T15:48:54 Z velislavgarkov The Big Prize (IOI17_prize) C++14
90 / 100
42 ms 600 KB
#include "prize.h"
#include <iostream>
using namespace std;
vector <int> a;
int maxs;
int cur[512];
int find_prize(int l, int r, int bigl, int bigr) {
    int mid=(l+r)/2;
    while (mid<=r) {
        a=ask(mid);
        if (a[0]+a[1]==0) return mid;
        if (a[0]+a[1]==maxs) break;
        mid++;
    }
    int ans=-1;
    if (mid<=r && a[0]+1<=bigr) {
        ans=find_prize(mid+1,r,a[0]+1,bigr);
        if (ans!=-1) return ans;
    }
    mid=(l+r)/2-1;
    while (mid>=l) {
        a=ask(mid);
        if (a[0]+a[1]==0) return mid;
        if (a[0]+a[1]==maxs) break;
        mid--;
    }
    if (mid>=l && a[0]>=bigl) {
        ans=find_prize(l,mid-1,bigl,a[0]);
        if (ans!=-1) return ans;
    }
    return ans;
}
int find_best(int n) {
    for (int i=0;i<500;i++) {
        a=ask(i);
        if (a[0]+a[1]==0) return i;
        maxs=max(maxs,a[0]+a[1]);
        cur[i]=a[0]+a[1];
    }
    int cnt=0;
    for (int i=0;i<500;i++) if (cur[i]!=maxs) cnt++;
    int ans=find_prize(0,n-1,cnt+1,maxs);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 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 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 500 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 4 ms 340 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 7 ms 344 KB Output is correct
15 Partially correct 31 ms 344 KB Partially correct - number of queries: 6597
16 Correct 8 ms 344 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 3 ms 428 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 21 ms 344 KB Output is correct
21 Partially correct 25 ms 344 KB Partially correct - number of queries: 5242
22 Partially correct 32 ms 600 KB Partially correct - number of queries: 5793
23 Correct 3 ms 344 KB Output is correct
24 Correct 6 ms 344 KB Output is correct
25 Correct 15 ms 344 KB Output is correct
26 Correct 15 ms 596 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 4 ms 600 KB Output is correct
29 Correct 4 ms 344 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 3 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Partially correct 24 ms 428 KB Partially correct - number of queries: 5728
35 Correct 3 ms 344 KB Output is correct
36 Partially correct 28 ms 344 KB Partially correct - number of queries: 6278
37 Correct 5 ms 600 KB Output is correct
38 Correct 3 ms 344 KB Output is correct
39 Correct 26 ms 436 KB Output is correct
40 Correct 2 ms 344 KB Output is correct
41 Correct 15 ms 344 KB Output is correct
42 Correct 19 ms 344 KB Output is correct
43 Correct 16 ms 344 KB Output is correct
44 Partially correct 26 ms 344 KB Partially correct - number of queries: 5147
45 Partially correct 19 ms 340 KB Partially correct - number of queries: 5193
46 Correct 2 ms 344 KB Output is correct
47 Correct 24 ms 344 KB Output is correct
48 Correct 11 ms 344 KB Output is correct
49 Partially correct 35 ms 600 KB Partially correct - number of queries: 7547
50 Correct 2 ms 344 KB Output is correct
51 Partially correct 23 ms 344 KB Partially correct - number of queries: 5146
52 Partially correct 35 ms 344 KB Partially correct - number of queries: 7978
53 Correct 2 ms 344 KB Output is correct
54 Correct 21 ms 344 KB Output is correct
55 Correct 2 ms 344 KB Output is correct
56 Correct 2 ms 344 KB Output is correct
57 Correct 11 ms 600 KB Output is correct
58 Correct 20 ms 600 KB Output is correct
59 Correct 13 ms 344 KB Output is correct
60 Correct 15 ms 344 KB Output is correct
61 Correct 2 ms 344 KB Output is correct
62 Correct 3 ms 344 KB Output is correct
63 Correct 3 ms 344 KB Output is correct
64 Correct 3 ms 344 KB Output is correct
65 Correct 2 ms 344 KB Output is correct
66 Correct 4 ms 344 KB Output is correct
67 Correct 4 ms 344 KB Output is correct
68 Correct 2 ms 344 KB Output is correct
69 Correct 4 ms 344 KB Output is correct
70 Correct 4 ms 600 KB Output is correct
71 Partially correct 33 ms 344 KB Partially correct - number of queries: 9537
72 Correct 6 ms 344 KB Output is correct
73 Partially correct 36 ms 344 KB Partially correct - number of queries: 9418
74 Partially correct 38 ms 344 KB Partially correct - number of queries: 9469
75 Correct 3 ms 344 KB Output is correct
76 Partially correct 32 ms 344 KB Partially correct - number of queries: 8313
77 Partially correct 37 ms 344 KB Partially correct - number of queries: 8935
78 Correct 5 ms 344 KB Output is correct
79 Correct 24 ms 344 KB Output is correct
80 Partially correct 42 ms 344 KB Partially correct - number of queries: 8843
81 Partially correct 36 ms 344 KB Partially correct - number of queries: 8917
82 Partially correct 33 ms 344 KB Partially correct - number of queries: 8939
83 Correct 3 ms 344 KB Output is correct
84 Partially correct 36 ms 344 KB Partially correct - number of queries: 7459
85 Partially correct 39 ms 344 KB Partially correct - number of queries: 8976
86 Correct 2 ms 344 KB Output is correct
87 Correct 2 ms 344 KB Output is correct
88 Correct 2 ms 344 KB Output is correct
89 Correct 2 ms 340 KB Output is correct
90 Correct 3 ms 344 KB Output is correct
91 Correct 2 ms 340 KB Output is correct
92 Correct 2 ms 344 KB Output is correct
93 Correct 5 ms 344 KB Output is correct
94 Correct 4 ms 344 KB Output is correct
95 Correct 4 ms 540 KB Output is correct
96 Correct 4 ms 344 KB Output is correct
97 Correct 2 ms 344 KB Output is correct