답안 #47725

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47725 2018-05-06T18:28:57 Z SinByCos 커다란 상품 (IOI17_prize) C++14
20 / 100
73 ms 688 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{
          if(v[1] - ans[1] > 0) hi = mid - 1;
          else lo = mid + 1;
        }
      }
      p = lo + 1;
    }
		else assert(false);
  }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 248 KB Output is correct
2 Correct 5 ms 308 KB Output is correct
3 Correct 4 ms 444 KB Output is correct
4 Correct 5 ms 464 KB Output is correct
5 Correct 5 ms 508 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 5 ms 508 KB Output is correct
8 Correct 6 ms 508 KB Output is correct
9 Correct 5 ms 556 KB Output is correct
10 Correct 6 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 556 KB Output is correct
2 Correct 6 ms 556 KB Output is correct
3 Correct 4 ms 556 KB Output is correct
4 Correct 5 ms 556 KB Output is correct
5 Correct 6 ms 556 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Correct 7 ms 556 KB Output is correct
8 Correct 4 ms 560 KB Output is correct
9 Correct 5 ms 560 KB Output is correct
10 Correct 5 ms 560 KB Output is correct
11 Correct 8 ms 560 KB Output is correct
12 Correct 6 ms 560 KB Output is correct
13 Correct 8 ms 560 KB Output is correct
14 Correct 12 ms 560 KB Output is correct
15 Correct 17 ms 560 KB Output is correct
16 Partially correct 62 ms 560 KB Partially correct - number of queries: 7575
17 Correct 6 ms 560 KB Output is correct
18 Partially correct 73 ms 560 KB Partially correct - number of queries: 8808
19 Correct 3 ms 560 KB Output is correct
20 Correct 19 ms 560 KB Output is correct
21 Correct 24 ms 560 KB Output is correct
22 Correct 11 ms 560 KB Output is correct
23 Correct 3 ms 560 KB Output is correct
24 Correct 5 ms 560 KB Output is correct
25 Runtime error 40 ms 688 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Halted 0 ms 0 KB -