답안 #47724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47724 2018-05-06T18:27:23 Z SinByCos 커다란 상품 (IOI17_prize) C++14
90 / 100
94 ms 572 KB
#include <bits/stdc++.h>
#include "prize.h"
 
using namespace std;
 
const int MAXN = 2e5 + 5;
 
int find_best(int n){
  int sum = 0, p = 500;
  for(int i=0; i<min(n, 500); ++i){
    vector<int> v = ask(i);
    sum = max(sum, v[0] + v[1]);
    if(v[0] + v[1] == 0) return i;
  }
  while(p < n){
    vector<int> v = ask(p);
    if(v[0] + v[1] == 0) return p;
    int lo = p + 1, hi = n - 1, mid;
    if(v[0] + v[1] == sum){
      while(lo <= hi){
        mid = (lo + hi)/2;
        vector<int> ans = ask(mid);
        if(ans[0] + ans[1] == 0) return mid;
        if(lo == hi) break;
        if(ans[0] + ans[1] < sum) hi = mid;
        else if (ans[0]+ans[1] > sum) assert(false);
        else{
          assert(v[1]-ans[1]>=0);
          if(v[1] - ans[1] > 0) hi = mid - 1;
          else lo = mid + 1;
        }
      }
      p = lo + 1;
    }
		else p++;
  }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 248 KB Output is correct
2 Correct 6 ms 308 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 7 ms 460 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 7 ms 528 KB Output is correct
8 Correct 6 ms 528 KB Output is correct
9 Correct 6 ms 532 KB Output is correct
10 Correct 5 ms 532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 532 KB Output is correct
2 Correct 3 ms 532 KB Output is correct
3 Correct 4 ms 532 KB Output is correct
4 Correct 4 ms 532 KB Output is correct
5 Correct 7 ms 532 KB Output is correct
6 Correct 2 ms 532 KB Output is correct
7 Correct 5 ms 532 KB Output is correct
8 Correct 4 ms 532 KB Output is correct
9 Correct 5 ms 532 KB Output is correct
10 Correct 5 ms 532 KB Output is correct
11 Correct 5 ms 532 KB Output is correct
12 Correct 6 ms 532 KB Output is correct
13 Correct 10 ms 532 KB Output is correct
14 Correct 4 ms 532 KB Output is correct
15 Correct 12 ms 532 KB Output is correct
16 Partially correct 54 ms 532 KB Partially correct - number of queries: 7575
17 Correct 3 ms 532 KB Output is correct
18 Partially correct 75 ms 544 KB Partially correct - number of queries: 8808
19 Correct 5 ms 556 KB Output is correct
20 Correct 14 ms 556 KB Output is correct
21 Correct 27 ms 556 KB Output is correct
22 Correct 10 ms 556 KB Output is correct
23 Correct 5 ms 556 KB Output is correct
24 Correct 5 ms 560 KB Output is correct
25 Partially correct 44 ms 560 KB Partially correct - number of queries: 5174
26 Partially correct 22 ms 560 KB Partially correct - number of queries: 5113
27 Correct 6 ms 560 KB Output is correct
28 Partially correct 58 ms 560 KB Partially correct - number of queries: 8385
29 Partially correct 26 ms 560 KB Partially correct - number of queries: 6460
30 Partially correct 79 ms 560 KB Partially correct - number of queries: 8742
31 Correct 5 ms 560 KB Output is correct
32 Correct 10 ms 560 KB Output is correct
33 Correct 2 ms 560 KB Output is correct
34 Correct 29 ms 560 KB Output is correct
35 Correct 9 ms 560 KB Output is correct
36 Correct 11 ms 560 KB Output is correct
37 Correct 4 ms 560 KB Output is correct
38 Correct 6 ms 560 KB Output is correct
39 Correct 45 ms 560 KB Output is correct
40 Partially correct 53 ms 560 KB Partially correct - number of queries: 7542
41 Partially correct 57 ms 560 KB Partially correct - number of queries: 5455
42 Partially correct 21 ms 560 KB Partially correct - number of queries: 5455
43 Correct 51 ms 560 KB Output is correct
44 Correct 37 ms 560 KB Output is correct
45 Correct 34 ms 560 KB Output is correct
46 Correct 5 ms 560 KB Output is correct
47 Correct 19 ms 560 KB Output is correct
48 Partially correct 26 ms 560 KB Partially correct - number of queries: 6634
49 Correct 8 ms 560 KB Output is correct
50 Partially correct 66 ms 560 KB Partially correct - number of queries: 8797
51 Correct 31 ms 560 KB Output is correct
52 Correct 6 ms 560 KB Output is correct
53 Correct 6 ms 560 KB Output is correct
54 Correct 32 ms 560 KB Output is correct
55 Correct 4 ms 560 KB Output is correct
56 Partially correct 94 ms 560 KB Partially correct - number of queries: 8797
57 Partially correct 45 ms 560 KB Partially correct - number of queries: 6560
58 Partially correct 58 ms 560 KB Partially correct - number of queries: 6661
59 Partially correct 34 ms 560 KB Partially correct - number of queries: 5455
60 Partially correct 53 ms 560 KB Partially correct - number of queries: 5098
61 Correct 7 ms 560 KB Output is correct
62 Correct 5 ms 560 KB Output is correct
63 Correct 7 ms 560 KB Output is correct
64 Correct 6 ms 560 KB Output is correct
65 Correct 6 ms 560 KB Output is correct
66 Correct 11 ms 560 KB Output is correct
67 Correct 7 ms 560 KB Output is correct
68 Correct 5 ms 560 KB Output is correct
69 Correct 11 ms 560 KB Output is correct
70 Correct 6 ms 560 KB Output is correct
71 Partially correct 43 ms 560 KB Partially correct - number of queries: 8756
72 Correct 9 ms 560 KB Output is correct
73 Partially correct 58 ms 560 KB Partially correct - number of queries: 8648
74 Partially correct 62 ms 560 KB Partially correct - number of queries: 8696
75 Correct 7 ms 560 KB Output is correct
76 Partially correct 71 ms 560 KB Partially correct - number of queries: 7560
77 Partially correct 85 ms 560 KB Partially correct - number of queries: 8823
78 Correct 8 ms 560 KB Output is correct
79 Correct 34 ms 572 KB Output is correct
80 Partially correct 63 ms 572 KB Partially correct - number of queries: 8836
81 Partially correct 60 ms 572 KB Partially correct - number of queries: 8841
82 Partially correct 59 ms 572 KB Partially correct - number of queries: 8737
83 Correct 4 ms 572 KB Output is correct
84 Partially correct 51 ms 572 KB Partially correct - number of queries: 7276
85 Partially correct 78 ms 572 KB Partially correct - number of queries: 8800
86 Correct 6 ms 572 KB Output is correct
87 Correct 5 ms 572 KB Output is correct
88 Correct 3 ms 572 KB Output is correct
89 Correct 5 ms 572 KB Output is correct
90 Correct 6 ms 572 KB Output is correct
91 Correct 5 ms 572 KB Output is correct
92 Correct 4 ms 572 KB Output is correct
93 Correct 7 ms 572 KB Output is correct
94 Correct 5 ms 572 KB Output is correct
95 Correct 9 ms 572 KB Output is correct
96 Correct 9 ms 572 KB Output is correct
97 Correct 6 ms 572 KB Output is correct