답안 #804728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
804728 2023-08-03T11:03:47 Z Benmath 커다란 상품 (IOI17_prize) C++14
90 / 100
78 ms 336 KB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;



int find_best(int n) {
    int maxi=0;
    if(n<10000){
        for(int i=0;i<=(n-1);i++){
            vector<int>res = ask(i);
            if((res[0]+res[1])==0){
                return i;
            }
        }
    }
    for(int i=0;i<600;i++){
        vector<int>res=ask(i);
        if((res[0]+res[1])==0){
            return i;
        }
        if((res[0]+res[1])>maxi){
            maxi=res[0]+res[1];
        }
    }
    int tren=-1;
    int left=0;
    vector<int>res=ask(0);
    if((res[0]+res[1])<maxi){
        tren=0;
        left++;
    }else{
        int ans=n;
        int l=0;
        int r=n-1;
        while(l<=r){
            int mid=(l+r)/2;
            vector<int>res=ask(mid);
            if((res[0]+res[1])==0){
                return mid;
            }
            if((res[0]+res[1])<maxi){
                ans=min(ans,mid);
                r=mid-1;
            }else{
                if(res[0]>left){
                    r=mid-1;
                }else{
                    l=mid+1;
                }
            }
        }
        tren=ans;
        left++;
    }
    int t1=0;
    while(t1==0){
        int ans=n;
        int l=tren+1;
        int r=n-1;
        while(l<=r){
            int mid=(l+r)/2;
            vector<int>res=ask(mid);
            if((res[0]+res[1])==0){
                return mid;
            }
            if((res[0]+res[1])<maxi){
                ans=min(ans,mid);
                r=mid-1;
            }else{
                if(res[0]>left){
                    r=mid-1;
                }else{
                    l=mid+1;
                }
            }
        }
        tren=ans;
        left++;
        
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:36:25: warning: control reaches end of non-void function [-Wreturn-type]
   36 |     vector<int>res=ask(0);
      |                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 292 KB Output is correct
2 Correct 2 ms 284 KB Output is correct
3 Correct 4 ms 292 KB Output is correct
4 Correct 5 ms 276 KB Output is correct
5 Correct 4 ms 284 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 6 ms 296 KB Output is correct
8 Correct 5 ms 292 KB Output is correct
9 Correct 6 ms 292 KB Output is correct
10 Correct 6 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 6 ms 292 KB Output is correct
3 Correct 7 ms 288 KB Output is correct
4 Correct 3 ms 296 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 0 ms 292 KB Output is correct
7 Correct 7 ms 296 KB Output is correct
8 Correct 3 ms 288 KB Output is correct
9 Correct 3 ms 292 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 3 ms 292 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 6 ms 276 KB Output is correct
14 Correct 9 ms 208 KB Output is correct
15 Correct 7 ms 284 KB Output is correct
16 Partially correct 48 ms 276 KB Partially correct - number of queries: 7150
17 Correct 5 ms 268 KB Output is correct
18 Partially correct 78 ms 292 KB Partially correct - number of queries: 8266
19 Correct 4 ms 272 KB Output is correct
20 Correct 15 ms 296 KB Output is correct
21 Correct 27 ms 268 KB Output is correct
22 Correct 11 ms 268 KB Output is correct
23 Correct 4 ms 272 KB Output is correct
24 Correct 6 ms 272 KB Output is correct
25 Correct 18 ms 272 KB Output is correct
26 Correct 42 ms 296 KB Output is correct
27 Correct 2 ms 292 KB Output is correct
28 Partially correct 60 ms 208 KB Partially correct - number of queries: 7924
29 Partially correct 37 ms 288 KB Partially correct - number of queries: 6146
30 Partially correct 30 ms 284 KB Partially correct - number of queries: 8201
31 Correct 2 ms 288 KB Output is correct
32 Correct 4 ms 288 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 11 ms 292 KB Output is correct
35 Correct 3 ms 292 KB Output is correct
36 Correct 16 ms 272 KB Output is correct
37 Correct 8 ms 292 KB Output is correct
38 Correct 6 ms 292 KB Output is correct
39 Correct 16 ms 272 KB Output is correct
40 Partially correct 23 ms 292 KB Partially correct - number of queries: 7091
41 Partially correct 19 ms 292 KB Partially correct - number of queries: 5210
42 Partially correct 35 ms 268 KB Partially correct - number of queries: 5210
43 Correct 17 ms 272 KB Output is correct
44 Correct 23 ms 272 KB Output is correct
45 Correct 23 ms 288 KB Output is correct
46 Correct 3 ms 208 KB Output is correct
47 Correct 26 ms 208 KB Output is correct
48 Partially correct 44 ms 208 KB Partially correct - number of queries: 6290
49 Correct 5 ms 284 KB Output is correct
50 Partially correct 40 ms 268 KB Partially correct - number of queries: 8255
51 Correct 23 ms 272 KB Output is correct
52 Correct 5 ms 280 KB Output is correct
53 Correct 3 ms 300 KB Output is correct
54 Correct 14 ms 288 KB Output is correct
55 Correct 4 ms 272 KB Output is correct
56 Partially correct 42 ms 272 KB Partially correct - number of queries: 8263
57 Partially correct 57 ms 208 KB Partially correct - number of queries: 6211
58 Partially correct 21 ms 292 KB Partially correct - number of queries: 6307
59 Partially correct 45 ms 208 KB Partially correct - number of queries: 5210
60 Correct 31 ms 276 KB Output is correct
61 Correct 6 ms 208 KB Output is correct
62 Correct 6 ms 296 KB Output is correct
63 Correct 3 ms 292 KB Output is correct
64 Correct 7 ms 296 KB Output is correct
65 Correct 10 ms 276 KB Output is correct
66 Correct 32 ms 272 KB Output is correct
67 Correct 3 ms 292 KB Output is correct
68 Correct 3 ms 268 KB Output is correct
69 Correct 22 ms 292 KB Output is correct
70 Correct 3 ms 284 KB Output is correct
71 Partially correct 28 ms 288 KB Partially correct - number of queries: 8401
72 Correct 9 ms 208 KB Output is correct
73 Partially correct 76 ms 208 KB Partially correct - number of queries: 8286
74 Partially correct 71 ms 208 KB Partially correct - number of queries: 8338
75 Correct 7 ms 208 KB Output is correct
76 Partially correct 37 ms 208 KB Partially correct - number of queries: 7233
77 Partially correct 71 ms 296 KB Partially correct - number of queries: 8299
78 Correct 9 ms 288 KB Output is correct
79 Correct 24 ms 208 KB Output is correct
80 Partially correct 67 ms 292 KB Partially correct - number of queries: 8285
81 Partially correct 58 ms 208 KB Partially correct - number of queries: 8283
82 Partially correct 51 ms 208 KB Partially correct - number of queries: 8227
83 Correct 6 ms 208 KB Output is correct
84 Partially correct 41 ms 292 KB Partially correct - number of queries: 6865
85 Partially correct 59 ms 208 KB Partially correct - number of queries: 8302
86 Partially correct 53 ms 208 KB Partially correct - number of queries: 8609
87 Correct 6 ms 208 KB Output is correct
88 Partially correct 42 ms 292 KB Partially correct - number of queries: 8150
89 Partially correct 66 ms 216 KB Partially correct - number of queries: 8541
90 Correct 9 ms 256 KB Output is correct
91 Partially correct 34 ms 288 KB Partially correct - number of queries: 5209
92 Partially correct 51 ms 208 KB Partially correct - number of queries: 8184
93 Partially correct 54 ms 208 KB Partially correct - number of queries: 8601
94 Partially correct 33 ms 208 KB Partially correct - number of queries: 8598
95 Partially correct 77 ms 208 KB Partially correct - number of queries: 8588
96 Partially correct 46 ms 236 KB Partially correct - number of queries: 8515
97 Partially correct 50 ms 208 KB Partially correct - number of queries: 8184